Package io.crate.types

Examples of io.crate.types.DataType


    @Test
    public void testAnyGreater() throws Exception {
        // 0.0 < ANY_OF (d_array)

        DataType doubleArrayType = new ArrayType(DataTypes.DOUBLE);
        Reference doubleArrayRef = createReference("d_array", doubleArrayType);
        FunctionImplementation anyGreaterImpl = functions.get(new FunctionIdent("any_>",
                Arrays.<DataType>asList(doubleArrayType, DataTypes.DOUBLE)));

        Function whereClause = new Function(anyGreaterImpl.info(), Arrays.<Symbol>asList(doubleArrayRef, Literal.newLiteral(0.0)));
View Full Code Here


    @Test
    public void testAnyGreaterEquals() throws Exception {
        // 0.0 <= ANY_OF (d_array)

        DataType doubleArrayType = new ArrayType(DataTypes.DOUBLE);
        Reference doubleArrayRef = createReference("d_array", doubleArrayType);
        FunctionImplementation anyGreaterImpl = functions.get(new FunctionIdent("any_>=",
                Arrays.<DataType>asList(doubleArrayType, DataTypes.DOUBLE)));

        Function whereClause = new Function(anyGreaterImpl.info(),
View Full Code Here

        assertThat(actual, is(expected));
    }

    @Test
    public void testNormalizeWithReference() throws Exception {
        final DataType arrayType = new ArrayType(DataTypes.STRING);
        ToLongArrayFunction impl = (ToLongArrayFunction)functions.get(
                new FunctionIdent(ToLongArrayFunction.NAME, ImmutableList.of(arrayType)));

        Reference foo = TestingHelpers.createReference("foo", arrayType);
        Symbol symbol = impl.normalizeSymbol(new Function(impl.info(), Arrays.<Symbol>asList(foo)));
View Full Code Here

        assertThat(eval(null, DataTypes.LONG), Matchers.nullValue());
        assertThat(eval(null, DataTypes.STRING), Matchers.nullValue());
    }

    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToLongArrayFunction impl = (ToLongArrayFunction)functions.get(
                new FunctionIdent(ToLongArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

        assertThat(actual, is(expected));
    }


    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToByteArrayFunction impl = (ToByteArrayFunction)functions.get(
                new FunctionIdent(ToByteArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

        assertThat(actual, is(expected));
    }


    private Object[] eval(final Object objects, DataType innerType) {
        final DataType arrayType = new ArrayType(innerType);
        ToDoubleArrayFunction impl = (ToDoubleArrayFunction)functions.get(
                new FunctionIdent(ToDoubleArrayFunction.NAME, ImmutableList.of(arrayType)));

        Literal input = new Literal() {
            @Override
View Full Code Here

        assertLiteralSymbol(symbol, 152462.70754934277);
    }

    @Test
    public void testNormalizeWithDoubleArray() throws Exception {
        DataType type = new ArrayType(DataTypes.DOUBLE);
        Symbol symbol = normalize(Arrays.<Symbol>asList(
                Literal.newLiteral(type, new Double[]{10.0, 20.0}),
                Literal.newLiteral(type, new Double[]{11.0, 21.0})
        ));
        assertLiteralSymbol(symbol, 152462.70754934277);
View Full Code Here

    @Override
    public FunctionImplementation<Function> getForTypes(List<DataType> dataTypes) throws IllegalArgumentException {
        Preconditions.checkArgument(dataTypes.size() == 2
                && DataTypes.isCollectionType(dataTypes.get(0))
                && dataTypes.get(1) == DataTypes.INTEGER);
        DataType returnType = ((CollectionType)dataTypes.get(0)).innerType();
        return new SubscriptFunction(createInfo(dataTypes, returnType));
    }
View Full Code Here

    @Override
    public Symbol normalizeSymbol(Function symbol) {
        Symbol arg1 = symbol.arguments().get(0);
        Symbol arg2 = symbol.arguments().get(1);
        DataType arg1Type = DataTypeVisitor.fromSymbol(arg1);
        DataType arg2Type = DataTypeVisitor.fromSymbol(arg2);

        boolean arg1IsReference = true;
        boolean literalConverted = false;
        short numLiterals = 0;

        if (arg1.symbolType().isValueSymbol()) {
            numLiterals++;
            arg1IsReference = false;
            if (!arg1Type.equals(DataTypes.GEO_POINT)) {
                literalConverted = true;
                arg1 = Literal.toLiteral(arg1, DataTypes.GEO_POINT);
            }
        } else {
            validateType(arg1, arg1Type);
        }

        if (arg2.symbolType().isValueSymbol()) {
            numLiterals++;
            if (!arg2Type.equals(DataTypes.GEO_POINT)) {
                literalConverted = true;
                arg2 = Literal.toLiteral(arg2, DataTypes.GEO_POINT);
            }
        } else {
            validateType(arg2, arg2Type);
View Full Code Here

    @Override
    public Symbol normalizeSymbol(Function symbol) {
        Symbol left = symbol.arguments().get(0);
        Symbol right = symbol.arguments().get(1);
        DataType leftType = DataTypeVisitor.fromSymbol(left);
        DataType rightType = DataTypeVisitor.fromSymbol(right);

        boolean literalConverted = false;
        short numLiterals = 0;

        if (left.symbolType().isValueSymbol()) {
            numLiterals++;
            if (leftType.equals(DataTypes.STRING)) {
                left = Literal.toLiteral(left, DataTypes.GEO_SHAPE);
                literalConverted = true;
            }
        } else {
            ensureShapeOrPoint(leftType);
        }

        if (right.symbolType().isValueSymbol()) {
            numLiterals++;
            if (rightType.equals(DataTypes.STRING)) {
                right = Literal.toLiteral(right, DataTypes.GEO_SHAPE);
                literalConverted = true;
            }
        } else {
            ensureShapeOrPoint(rightType);
View Full Code Here

TOP

Related Classes of io.crate.types.DataType

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.