Package io.crate.planner.symbol

Examples of io.crate.planner.symbol.Literal


        assertThat(((Function) result).info().ident().name(), is(InOperator.NAME));
    }

    @Test
    public void testNormalizeSymbolSetLiteralStringIncluded() {
        Literal inValue = Literal.newLiteral("charlie");
        Literal inListValues = Literal.newLiteral(
                STRING_SET_TYPE,
                Sets.newHashSet(
                        new BytesRef("alpha"),
                        new BytesRef("bravo"),
                        new BytesRef("charlie"),
View Full Code Here


    private Boolean anyLikeNormalize(String pattern, String ... expressions) {
        return (Boolean)((Literal)normalizeSymbol(pattern, expressions)).value();
    }

    private Boolean anyLike(String pattern, String ... expressions) {
        Literal patternLiteral = Literal.newLiteral(pattern);
        Object[] value = new Object[expressions.length];
        for (int i=0; i < expressions.length; i++) {
            value[i] = expressions[i] == null ? null : new BytesRef(expressions[i]);
        }
        Literal valuesLiteral = Literal.newLiteral(new ArrayType(DataTypes.STRING), value);
        AnyLikeOperator impl = (AnyLikeOperator)new AnyLikeOperator.AnyLikeResolver().getForTypes(
                Arrays.asList(valuesLiteral.valueType(), DataTypes.STRING)
        );

        return impl.evaluate(valuesLiteral, patternLiteral);
    }
View Full Code Here

        assertLiteralSymbol(result, true);
    }

    @Test
    public void testNormalizeSymbolSetLiteralStringNotIncluded() {
        Literal inValue = Literal.newLiteral("not included");
        Literal inListValues = Literal.newLiteral(
                STRING_SET_TYPE,
                Sets.newHashSet(
                        new BytesRef("alpha"),
                        new BytesRef("bravo"),
                        new BytesRef("charlie"),
View Full Code Here

        assertNull(anyLikeNormalize(null, "bar"));
    }

    @Test
    public void testNegateLike() throws Exception {
        Literal patternLiteral = Literal.newLiteral("A");
        Literal valuesLiteral = Literal.newLiteral(new ArrayType(DataTypes.STRING),
                new Object[]{new BytesRef("A"), new BytesRef("B")});
        FunctionImplementation<Function> impl = new AnyLikeOperator.AnyLikeResolver().getForTypes(
                Arrays.asList(valuesLiteral.valueType(), DataTypes.STRING)
        );
        Function anyLikeFunction = new Function(impl.info(), Arrays.<Symbol>asList(valuesLiteral, patternLiteral));
        Input<Boolean> normalized = (Input<Boolean>) impl.normalizeSymbol(anyLikeFunction);
        assertThat(normalized.value(), is(true));
        assertThat(new NotPredicate().evaluate(normalized), is(false));
View Full Code Here

                Arrays.<DataType>asList(DataTypes.STRING, new SetType(DataTypes.STRING))
        ));

        ImmutableSet<BytesRef> list = ImmutableSet.of(
                new BytesRef("alpha"), new BytesRef("bravo"), new BytesRef("charlie"));
        Literal set = Literal.newLiteral(new SetType(DataTypes.STRING), list);
        Function inList = new Function(inListImpl.info(), Arrays.<Symbol>asList(ref, set));

        BytesReference reference = generator.convert(new WhereClause(inList));
        Tuple<XContentType, Map<String, Object>> actualMap =
                XContentHelper.convertToMap(reference, true);
View Full Code Here

import static org.junit.Assert.*;

public class AnyNotLikeOperatorTest {

    private static Symbol normalizeSymbol(String pattern, String ... expressions) {
        Literal patternLiteral = Literal.newLiteral(pattern);
        Object[] value = new Object[expressions.length];
        for (int i=0; i < expressions.length; i++) {
            value[i] = expressions[i] == null ? null : new BytesRef(expressions[i]);
        }
        Literal valuesLiteral = Literal.newLiteral(new ArrayType(DataTypes.STRING), value);
        AnyNotLikeOperator impl = (AnyNotLikeOperator)new AnyNotLikeOperator.AnyNotLikeResolver().getForTypes(
                Arrays.asList(valuesLiteral.valueType(), patternLiteral.valueType())
        );

        Function function = new Function(
                impl.info(),
                Arrays.<Symbol>asList(valuesLiteral, patternLiteral)
View Full Code Here

    private Boolean anyNotLikeNormalize(String pattern, String ... expressions) {
        return (Boolean)((Literal)normalizeSymbol(pattern, expressions)).value();
    }

    private Boolean anyNotLike(String pattern, String ... expressions) {
        Literal patternLiteral = Literal.newLiteral(pattern);
        Object[] value = new Object[expressions.length];
        for (int i=0; i < expressions.length; i++) {
            value[i] = expressions[i] == null ? null : new BytesRef(expressions[i]);
        }
        Literal valuesLiteral = Literal.newLiteral(new ArrayType(DataTypes.STRING), value);
        AnyNotLikeOperator impl = (AnyNotLikeOperator)new AnyNotLikeOperator.AnyNotLikeResolver().getForTypes(
                Arrays.asList(valuesLiteral.valueType(), DataTypes.STRING)
        );

        return impl.evaluate(valuesLiteral, patternLiteral);
    }
View Full Code Here

        assertNull(anyNotLikeNormalize(null, "bar"));
    }

    @Test
    public void testNegateNotLike() throws Exception {
        Literal patternLiteral = Literal.newLiteral("A");
        Literal valuesLiteral = Literal.newLiteral(new ArrayType(DataTypes.STRING),
                new Object[]{new BytesRef("A"), new BytesRef("B")});
        FunctionImplementation<Function> impl = new AnyNotLikeOperator.AnyNotLikeResolver().getForTypes(
                Arrays.asList(valuesLiteral.valueType(), DataTypes.STRING)
        );
        Function anyNotLikeFunction = new Function(impl.info(), Arrays.<Symbol>asList(valuesLiteral, patternLiteral));
        Input<Boolean> normalized = (Input<Boolean>) impl.normalizeSymbol(anyNotLikeFunction);
        assertThat(normalized.value(), is(true));
        assertThat(new NotPredicate().evaluate(normalized), is(false));
View Full Code Here

    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
            public Object value() {
                return objects;
            }
View Full Code Here

    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
            public Object value() {
                return objects;
            }
View Full Code Here

TOP

Related Classes of io.crate.planner.symbol.Literal

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.