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);
}
Aggregations