Package io.crate.types

Examples of io.crate.types.ArrayType


    @Test
    public void testForValueWithList() {
        List<String> strings = Arrays.asList("foo", "bar");
        DataType dataType = DataTypes.guessType(strings);
        assertEquals(dataType, new ArrayType(DataTypes.STRING));

        List<Integer> integers = Arrays.asList(1, 2, 3);
        dataType = DataTypes.guessType(integers);
        assertEquals(dataType, new ArrayType(DataTypes.INTEGER));
    }
View Full Code Here


    @Test
    public void testForValueWithArray() {
        Boolean[] booleans = new Boolean[] {true, false};
        DataType dataType = DataTypes.guessType(booleans);
        assertEquals(dataType, new ArrayType(DataTypes.BOOLEAN));
    }
View Full Code Here

    @Test
    public void testForValueWithTimestampArrayAsString() {
        String[] strings = {"2013-09-10T21:51:43", "2013-11-10T21:51:43"};
        DataType dataType = DataTypes.guessType(strings, false);
        assertEquals(dataType, new ArrayType(DataTypes.TIMESTAMP));
    }
View Full Code Here

        objBNested.put("bn1", 1);
        objBNested.put("bn2", 2);

        List<Object> objects = Arrays.<Object>asList(objA, objB);
        DataType dataType = DataTypes.guessType(objects);
        assertEquals(dataType, new ArrayType(DataTypes.OBJECT));
    }
View Full Code Here

    }

    @Test
    public void testForValueWithArrayWithNullValues() {
        DataType dataType = DataTypes.guessType(new String[]{"foo", null, "bar"});
        assertEquals(dataType, new ArrayType(DataTypes.STRING));
    }
View Full Code Here

    @Test
    public void testForValueNestedList() {
        List<List<String>> nestedStrings = Arrays.asList(
                Arrays.asList("foo", "bar"),
                Arrays.asList("f", "b"));
        assertEquals(new ArrayType(new ArrayType(DataTypes.STRING)), DataTypes.guessType(nestedStrings));
    }
View Full Code Here

    @Test
    public void testForValueWithEmptyList() {
        List<Object> objects = Arrays.<Object>asList();
        DataType type = DataTypes.guessType(objects);
        assertEquals(type, new ArrayType(DataTypes.UNDEFINED));
    }
View Full Code Here

            // return references of primitive types as arrays
            info = new ReferenceInfo.Builder()
                    .ident(info.ident())
                    .columnPolicy(info.columnPolicy())
                    .granularity(info.granularity())
                    .type(new ArrayType(info.type()))
                    .build();
        }

        return info;
    }
View Full Code Here

            childImplementations.add(new NullFieldSysObjectReference());
        }

        @Override
        public ReferenceInfo info() {
            return new ReferenceInfo(new ReferenceIdent(new TableIdent("bla", "blubb"), "foo"), RowGranularity.DOC, new ArrayType(DataTypes.STRING));
        }
View Full Code Here

    private static class Resolver implements DynamicFunctionResolver {
        @Override
        public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
            Preconditions.checkArgument(dataTypes.size() == 1, "Invalid number of arguments");
            Preconditions.checkArgument(DataTypes.isCollectionType(dataTypes.get(0)), "Argument must be a collection type");
            ArrayType arrayType = (ArrayType) dataTypes.get(0);
            // TODO: support geo inner types
            Preconditions.checkArgument(DataTypes.PRIMITIVE_TYPES.contains(arrayType.innerType()),
                    String.format(Locale.ENGLISH, "Array inner type '%s' not supported for conversion",
                            arrayType.innerType().getName()));
            return new ToStringArrayFunction(createInfo(dataTypes));
        }
View Full Code Here

TOP

Related Classes of io.crate.types.ArrayType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.