Search in sources :

Example 1 with MinMaxNStateSerializer

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

the class AbstractMinMaxNAggregationFunction method generateAggregation.

protected InternalAggregationFunction generateAggregation(Type type) {
    DynamicClassLoader classLoader = new DynamicClassLoader(AbstractMinMaxNAggregationFunction.class.getClassLoader());
    BlockComparator comparator = typeToComparator.apply(type);
    List<Type> inputTypes = ImmutableList.of(type, BIGINT);
    MinMaxNStateSerializer stateSerializer = new MinMaxNStateSerializer(comparator, type);
    Type intermediateType = stateSerializer.getSerializedType();
    ArrayType outputType = new ArrayType(type);
    List<ParameterMetadata> inputParameterMetadata = ImmutableList.of(new ParameterMetadata(STATE), new ParameterMetadata(BLOCK_INPUT_CHANNEL, type), new ParameterMetadata(INPUT_CHANNEL, BIGINT), new ParameterMetadata(BLOCK_INDEX));
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(getSignature().getName(), type.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), inputParameterMetadata, INPUT_FUNCTION.bindTo(comparator).bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(outputType), MinMaxNState.class, stateSerializer, new MinMaxNStateFactory(), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(getSignature().getName(), inputTypes, intermediateType, outputType, true, factory);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) MinMaxNStateSerializer(com.facebook.presto.operator.aggregation.state.MinMaxNStateSerializer) ParameterMetadata(com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata) ArrayType(com.facebook.presto.type.ArrayType) ArrayType(com.facebook.presto.type.ArrayType) Type(com.facebook.presto.spi.type.Type) MinMaxNStateFactory(com.facebook.presto.operator.aggregation.state.MinMaxNStateFactory)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 ParameterMetadata (com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata)1 MinMaxNStateFactory (com.facebook.presto.operator.aggregation.state.MinMaxNStateFactory)1 MinMaxNStateSerializer (com.facebook.presto.operator.aggregation.state.MinMaxNStateSerializer)1 Type (com.facebook.presto.spi.type.Type)1 ArrayType (com.facebook.presto.type.ArrayType)1