use of com.facebook.presto.operator.aggregation.state.HistogramStateFactory in project presto by prestodb.
the class Histogram method generateAggregation.
private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType) {
DynamicClassLoader classLoader = new DynamicClassLoader(Histogram.class.getClassLoader());
List<Type> inputTypes = ImmutableList.of(keyType);
Type outputType = new MapType(keyType, valueType);
HistogramStateSerializer stateSerializer = new HistogramStateSerializer(keyType);
Type intermediateType = stateSerializer.getSerializedType();
MethodHandle inputFunction = INPUT_FUNCTION.bindTo(keyType);
MethodHandle outputFunction = OUTPUT_FUNCTION.bindTo(outputType);
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(keyType), inputFunction, COMBINE_FUNCTION, outputFunction, HistogramState.class, stateSerializer, new HistogramStateFactory(), outputType);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, inputTypes, intermediateType, outputType, true, factory);
}
Aggregations