Search in sources :

Example 1 with StatisticalDigestStateSerializer

use of com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer in project presto by prestodb.

the class StatisticalDigestAggregationFunction method generateAggregation.

private InternalAggregationFunction generateAggregation(String name, Type valueType, Type outputType, int arity) {
    DynamicClassLoader classLoader = new DynamicClassLoader(StatisticalDigestAggregationFunction.class.getClassLoader());
    List<Type> inputTypes = getInputTypes(valueType, arity);
    StatisticalDigestStateSerializer stateSerializer = new StatisticalDigestStateSerializer();
    Type intermediateType = stateSerializer.getSerializedType();
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(name, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(inputTypes), getInputMethodHandle(valueType, arity), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(StatisticalDigestState.class, stateSerializer, factory)), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(name, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) Type(com.facebook.presto.common.type.Type) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) StatisticalDigestStateSerializer(com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer)

Example 2 with StatisticalDigestStateSerializer

use of com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer in project presto by prestodb.

the class MergeStatisticalDigestFunction method generateAggregation.

private InternalAggregationFunction generateAggregation(Type type) {
    DynamicClassLoader classLoader = new DynamicClassLoader(MapAggregationFunction.class.getClassLoader());
    StatisticalDigestStateSerializer stateSerializer = new StatisticalDigestStateSerializer();
    Type intermediateType = stateSerializer.getSerializedType();
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(name, type.getTypeSignature(), ImmutableList.of(type.getTypeSignature())), createInputParameterMetadata(type), getInputFunction().bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(StatisticalDigestState.class, stateSerializer, factory)), type);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(name, ImmutableList.of(type), ImmutableList.of(intermediateType), type, true, true, factory);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) Type(com.facebook.presto.common.type.Type) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) StatisticalDigestStateSerializer(com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)2 Type (com.facebook.presto.common.type.Type)2 AccumulatorStateDescriptor (com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)2 StatisticalDigestStateSerializer (com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer)2