Package io.crate.types

Examples of io.crate.types.ArrayType


    }

    @Test
    public void testNormalize() throws Exception {
        List<Symbol> arguments = Arrays.<Symbol>asList(
                Literal.newLiteral(new Integer[]{ 1, 2, 3 }, new ArrayType(DataTypes.INTEGER))
        );
        BytesRef[] expected = new BytesRef[]{ new BytesRef("1"), new BytesRef("2"), new BytesRef("3") };
        Function function = createFunction(ToStringArrayFunction.NAME, new ArrayType(DataTypes.STRING), arguments);
        ToStringArrayFunction arrayFunction = (ToStringArrayFunction) functions.get(function.info().ident());

        Symbol result = arrayFunction.normalizeSymbol(function);
        assertLiteralSymbol(result, expected, new ArrayType(DataTypes.STRING));

        arguments.set(0, Literal.newLiteral(new Float[]{ 1.0f, 2.0f, 3.0f }, new ArrayType(DataTypes.FLOAT)));
        expected = new BytesRef[]{ new BytesRef("1.0"), new BytesRef("2.0"), new BytesRef("3.0") };
        function = createFunction(ToStringArrayFunction.NAME, new ArrayType(DataTypes.STRING), arguments);
        arrayFunction = (ToStringArrayFunction) functions.get(function.info().ident());

        result = arrayFunction.normalizeSymbol(function);
        assertLiteralSymbol(result, expected, new ArrayType(DataTypes.STRING));
    }
View Full Code Here


    }

    @Test
    public void testEvaluate() throws Exception {
        List<Symbol> arguments = Arrays.<Symbol>asList(
                createReference("int_array", new ArrayType(DataTypes.INTEGER))
        );
        Object[] expected = new BytesRef[]{ new BytesRef("1"), new BytesRef("2"), new BytesRef("3") };
        Function function = createFunction(ToStringArrayFunction.NAME, new ArrayType(DataTypes.STRING), arguments);
        ToStringArrayFunction arrayFunction = (ToStringArrayFunction) functions.get(function.info().ident());

        Input[] args = new Input[1];
        args[0] = new Input<Object>() {
            @Override
View Full Code Here

    @Test
    public void testInvalidArgumentInnerType() throws Exception {
        expectedException.expect(IllegalArgumentException.class);
        expectedException.expectMessage("Array inner type 'object' not supported for conversion");
        functions.get(new FunctionIdent(ToStringArrayFunction.NAME, ImmutableList.<DataType>of(new ArrayType(DataTypes.OBJECT))));
    }
View Full Code Here

    @Test
    public void testEvaluate() throws Exception {
        final Literal<Object[]> term = Literal.newLiteral(
                new BytesRef[]{ new BytesRef("Youri"), new BytesRef("Ruben") },
                new ArrayType(DataTypes.STRING));
        final Literal<Integer> termIndex = Literal.newLiteral(1);
        final BytesRef expected = new BytesRef("Youri");

        List<Symbol> arguments = Arrays.<Symbol>asList(
                createReference("names", term.valueType()),
View Full Code Here

    @Test
    public void testNormalizeSymbol() throws Exception {
        final Literal<Object[]> term = Literal.newLiteral(
                new BytesRef[]{ new BytesRef("Youri"), new BytesRef("Ruben") },
                new ArrayType(DataTypes.STRING));
        final Literal<Integer> termIndex = Literal.newLiteral(1);
        final BytesRef expected = new BytesRef("Youri");
        List<Symbol> arguments = Arrays.<Symbol>asList(
                term,
                termIndex
View Full Code Here

    @Test
    public void testIndexOutOfRange() throws Exception {
        final Literal<Object[]> term = Literal.newLiteral(
                new BytesRef[]{ new BytesRef("Youri"), new BytesRef("Ruben") },
                new ArrayType(DataTypes.STRING));
        List<Symbol> arguments = Arrays.<Symbol>asList(
                term,
                Literal.newLiteral(3)
        );
        Function function = createFunction(SubscriptFunction.NAME, DataTypes.STRING, arguments);
View Full Code Here

                "Jeltz"
        );
        assertLiteralSymbol(
                analysis.assignments().get(new Reference(userTableInfo.getReferenceInfo(new ColumnIdent("friends")))),
                friends,
                new ArrayType(DataTypes.OBJECT)
        );
        assertLiteralSymbol(
                analysis.assignments().get(new Reference(userTableInfo.getReferenceInfo(new ColumnIdent("other_id")))),
                0L
        );
View Full Code Here

        functions.get(new FunctionIdent(ToBooleanArrayFunction.NAME, ImmutableList.<DataType>of(DataTypes.OBJECT)));
    }


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

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

        Function function = createFunction(MatchesFunction.NAME, DataTypes.STRING, arguments);
        MatchesFunction regexpImpl = (MatchesFunction) functions.get(function.info().ident());

        Symbol result = regexpImpl.normalizeSymbol(function);
        BytesRef[] expected = new BytesRef[]{ new BytesRef("ba") };
        assertLiteralSymbol(result, expected, new ArrayType(DataTypes.STRING));

        arguments = Arrays.<Symbol>asList(
                createReference("text", DataTypes.STRING),
                Literal.newLiteral(".*(ba).*")
        );
View Full Code Here

        Function function = createFunction(MatchesFunction.NAME, DataTypes.STRING, arguments);
        MatchesFunction regexpImpl = (MatchesFunction) functions.get(function.info().ident());

        Symbol result = regexpImpl.normalizeSymbol(function);
        BytesRef[] expected = new BytesRef[]{ new BytesRef("ba") };
        assertLiteralSymbol(result, expected, new ArrayType(DataTypes.STRING));
    }
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.