Search in sources :

Example 1 with HistogramStateFactory

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);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) MapType(com.facebook.presto.type.MapType) Type(com.facebook.presto.spi.type.Type) BigintType(com.facebook.presto.spi.type.BigintType) HistogramStateFactory(com.facebook.presto.operator.aggregation.state.HistogramStateFactory) MapType(com.facebook.presto.type.MapType) HistogramStateSerializer(com.facebook.presto.operator.aggregation.state.HistogramStateSerializer) MethodHandle(java.lang.invoke.MethodHandle)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 HistogramStateFactory (com.facebook.presto.operator.aggregation.state.HistogramStateFactory)1 HistogramStateSerializer (com.facebook.presto.operator.aggregation.state.HistogramStateSerializer)1 BigintType (com.facebook.presto.spi.type.BigintType)1 Type (com.facebook.presto.spi.type.Type)1 MapType (com.facebook.presto.type.MapType)1 MethodHandle (java.lang.invoke.MethodHandle)1