Search in sources :

Example 1 with FunctionInfo

use of io.crate.metadata.FunctionInfo in project crate by crate.

the class GroupingIntegerCollectorBenchmark method createGroupBySumCollector.

private GroupingCollector createGroupBySumCollector(Functions functions) {
    InputCollectExpression keyInput = new InputCollectExpression(0);
    List<Input<?>> keyInputs = Arrays.<Input<?>>asList(keyInput);
    CollectExpression[] collectExpressions = new CollectExpression[] { keyInput };
    FunctionIdent functionIdent = new FunctionIdent(SumAggregation.NAME, Arrays.asList(DataTypes.INTEGER));
    FunctionInfo functionInfo = new FunctionInfo(functionIdent, DataTypes.INTEGER, FunctionInfo.Type.AGGREGATE);
    AggregationFunction sumAgg = (AggregationFunction) functions.get(functionIdent);
    Aggregation aggregation = Aggregation.finalAggregation(functionInfo, Arrays.asList(new InputColumn(0)), Aggregation.Step.ITER);
    Aggregator[] aggregators = new Aggregator[] { new Aggregator(RAM_ACCOUNTING_CONTEXT, aggregation, sumAgg, new Input[] { keyInput }) };
    return GroupingCollector.singleKey(collectExpressions, aggregators, RAM_ACCOUNTING_CONTEXT, keyInputs.get(0), DataTypes.INTEGER);
}
Also used : AggregationFunction(io.crate.operation.aggregation.AggregationFunction) Aggregation(io.crate.analyze.symbol.Aggregation) SumAggregation(io.crate.operation.aggregation.impl.SumAggregation) FunctionIdent(io.crate.metadata.FunctionIdent) InputCollectExpression(io.crate.operation.collect.InputCollectExpression) InputColumn(io.crate.analyze.symbol.InputColumn) FunctionInfo(io.crate.metadata.FunctionInfo) Aggregator(io.crate.operation.aggregation.Aggregator) CollectExpression(io.crate.operation.collect.CollectExpression) InputCollectExpression(io.crate.operation.collect.InputCollectExpression)

Example 2 with FunctionInfo

use of io.crate.metadata.FunctionInfo in project crate by crate.

the class SymbolFormatterTest method testFormat.

@Test
public void testFormat() throws Exception {
    Function f = new Function(new FunctionInfo(new FunctionIdent("foo", Arrays.<DataType>asList(DataTypes.STRING, DataTypes.UNDEFINED)), DataTypes.DOUBLE), Arrays.<Symbol>asList(Literal.of("bar"), Literal.of(3.4)));
    assertThat(SymbolFormatter.format("This Symbol is formatted %s", f), is("This Symbol is formatted foo('bar', 3.4)"));
}
Also used : Function(io.crate.analyze.symbol.Function) FunctionIdent(io.crate.metadata.FunctionIdent) FunctionInfo(io.crate.metadata.FunctionInfo) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 3 with FunctionInfo

use of io.crate.metadata.FunctionInfo in project crate by crate.

the class FunctionTest method testCloning.

@Test
public void testCloning() throws Exception {
    Function fn = new Function(new FunctionInfo(new FunctionIdent(randomAsciiOfLength(10), ImmutableList.of(DataTypes.BOOLEAN)), TestingHelpers.randomPrimitiveType(), FunctionInfo.Type.SCALAR, randomFeatures()), Collections.singletonList(TestingHelpers.createReference(randomAsciiOfLength(2), DataTypes.BOOLEAN)));
    Function fn2 = fn.clone();
    assertThat(fn, is(equalTo(fn2)));
    assertThat(fn.hashCode(), is(fn2.hashCode()));
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) FunctionInfo(io.crate.metadata.FunctionInfo) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 4 with FunctionInfo

use of io.crate.metadata.FunctionInfo in project crate by crate.

the class PercentileAggregation method register.

public static void register(AggregationImplModule mod) {
    for (DataType<?> t : DataTypes.NUMERIC_PRIMITIVE_TYPES) {
        mod.register(new PercentileAggregation(new FunctionInfo(new FunctionIdent(NAME, ImmutableList.<DataType>of(t, DataTypes.DOUBLE)), DataTypes.DOUBLE, FunctionInfo.Type.AGGREGATE)));
        mod.register(new PercentileAggregation(new FunctionInfo(new FunctionIdent(NAME, ImmutableList.of(t, DataTypes.DOUBLE_ARRAY)), DataTypes.DOUBLE_ARRAY, FunctionInfo.Type.AGGREGATE)));
    }
}
Also used : FunctionIdent(io.crate.metadata.FunctionIdent) FunctionInfo(io.crate.metadata.FunctionInfo) DataType(io.crate.types.DataType)

Example 5 with FunctionInfo

use of io.crate.metadata.FunctionInfo in project crate by crate.

the class GroupingBytesRefCollectorBenchmark method createGroupByMinBytesRefCollector.

private GroupingCollector createGroupByMinBytesRefCollector(Functions functions) {
    InputCollectExpression keyInput = new InputCollectExpression(0);
    List<Input<?>> keyInputs = Arrays.<Input<?>>asList(keyInput);
    CollectExpression[] collectExpressions = new CollectExpression[] { keyInput };
    FunctionIdent minBytesRefFuncIdent = new FunctionIdent(MinimumAggregation.NAME, Arrays.asList(DataTypes.STRING));
    FunctionInfo minBytesRefFuncInfo = new FunctionInfo(minBytesRefFuncIdent, DataTypes.INTEGER, FunctionInfo.Type.AGGREGATE);
    AggregationFunction minAgg = (AggregationFunction) functions.get(minBytesRefFuncIdent);
    Aggregation aggregation = Aggregation.finalAggregation(minBytesRefFuncInfo, Arrays.asList(new InputColumn(0)), Aggregation.Step.ITER);
    Aggregator[] aggregators = new Aggregator[] { new Aggregator(RAM_ACCOUNTING_CONTEXT, aggregation, minAgg, new Input[] { keyInput }) };
    return GroupingCollector.singleKey(collectExpressions, aggregators, RAM_ACCOUNTING_CONTEXT, keyInputs.get(0), DataTypes.STRING);
}
Also used : AggregationFunction(io.crate.operation.aggregation.AggregationFunction) Aggregation(io.crate.analyze.symbol.Aggregation) MinimumAggregation(io.crate.operation.aggregation.impl.MinimumAggregation) FunctionIdent(io.crate.metadata.FunctionIdent) InputCollectExpression(io.crate.operation.collect.InputCollectExpression) InputColumn(io.crate.analyze.symbol.InputColumn) FunctionInfo(io.crate.metadata.FunctionInfo) Aggregator(io.crate.operation.aggregation.Aggregator) CollectExpression(io.crate.operation.collect.CollectExpression) InputCollectExpression(io.crate.operation.collect.InputCollectExpression)

Aggregations

FunctionInfo (io.crate.metadata.FunctionInfo)16 FunctionIdent (io.crate.metadata.FunctionIdent)13 DataType (io.crate.types.DataType)7 CrateUnitTest (io.crate.test.integration.CrateUnitTest)6 Test (org.junit.Test)6 Aggregation (io.crate.analyze.symbol.Aggregation)3 InputColumn (io.crate.analyze.symbol.InputColumn)2 AggregationFunction (io.crate.operation.aggregation.AggregationFunction)2 Aggregator (io.crate.operation.aggregation.Aggregator)2 CollectExpression (io.crate.operation.collect.CollectExpression)2 InputCollectExpression (io.crate.operation.collect.InputCollectExpression)2 SubscriptFunction (io.crate.operation.scalar.SubscriptFunction)2 AddFunction (io.crate.operation.scalar.arithmetic.AddFunction)2 DistanceFunction (io.crate.operation.scalar.geo.DistanceFunction)2 MatchesFunction (io.crate.operation.scalar.regex.MatchesFunction)2 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)2 StreamInput (org.elasticsearch.common.io.stream.StreamInput)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Function (com.google.common.base.Function)1 Function (io.crate.analyze.symbol.Function)1