Package io.crate.metadata

Examples of io.crate.metadata.FunctionIdent


    }

    @Test
    @SuppressWarnings("unchecked")
    public void testEvaluate() throws Exception {
        FunctionIdent ident = new FunctionIdent(ToIntFunction.NAME, ImmutableList.<DataType>of(DataTypes.STRING));
        Scalar<Object, Object> format = (Scalar<Object, Object>) functions.get(ident);
        Input<Object> arg1 = new Input<Object>() {
            @Override
            public Object value() {
                return "123";
            }
        };
        Object result = format.evaluate(arg1);
        assertThat((Integer)result, is(123));

        ident = new FunctionIdent(ToIntFunction.NAME, ImmutableList.<DataType>of(DataTypes.FLOAT));
        format = (Scalar<Object, Object>) functions.get(ident);
        arg1 = new Input<Object>() {
            @Override
            public Object value() {
                return 42.5f;
View Full Code Here


                .add(new ScalarFunctionModule()).createInjector().getInstance(Functions.class);
    }


    private ToNullFunction getFunction(DataType type) {
        return (ToNullFunction) functions.get(new FunctionIdent(functionName, Arrays.asList(type)));
    }
View Full Code Here

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

        functions = new ModulesBuilder().add(new OperatorModule()).createInjector().getInstance(Functions.class);
    }

    private EqOperator getOp(DataType dataType) {
        return (EqOperator) functions.get(
                new FunctionIdent(EqOperator.NAME, ImmutableList.of(dataType, dataType)));
    }
View Full Code Here

    @Test
    public void testNormalizeSymbolNonLiteral() {
        EqOperator op = getOp(DataTypes.INTEGER);
        Function f1 = new Function(
                new FunctionInfo(
                        new FunctionIdent("dummy_function", Arrays.<DataType>asList(DataTypes.INTEGER)),
                        DataTypes.INTEGER
                ),
                Arrays.<Symbol>asList(Literal.newLiteral(2))
        );

        Function f2 = new Function(
                new FunctionInfo(
                        new FunctionIdent("dummy_function", Arrays.<DataType>asList(DataTypes.INTEGER)),
                        DataTypes.INTEGER
                ),
                Arrays.<Symbol>asList(Literal.newLiteral(2))
        );
View Full Code Here

        ImmutableList<Input<?>> keys = ImmutableList.<Input<?>>of(
                new DummyInput("one", "one", "three"));


        FunctionInfo countInfo = new FunctionInfo(new FunctionIdent("count", ImmutableList.<DataType>of()), DataTypes.LONG);
        Aggregation countAggregation =
                new Aggregation(countInfo, ImmutableList.<Symbol>of(), Aggregation.Step.ITER, Aggregation.Step.PARTIAL);

        Functions functions = new ModulesBuilder()
                .add(new AggregationImplModule()).createInjector().getInstance(Functions.class);
View Full Code Here

                .add(new ScalarFunctionModule()).createInjector().getInstance(Functions.class);
    }


    private ToBooleanFunction getFunction(DataType type) {
        return (ToBooleanFunction) functions.get(new FunctionIdent(functionName, Arrays.asList(type)));
    }
View Full Code Here

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

                .add(new ScalarFunctionModule()).createInjector().getInstance(Functions.class);
    }


    private ToByteFunction getFunction(DataType type) {
        return (ToByteFunction) functions.get(new FunctionIdent(functionName, Arrays.asList(type)));
    }
View Full Code Here

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

TOP

Related Classes of io.crate.metadata.FunctionIdent

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.