Search in sources :

Example 1 with MapUnionSumStateSerializer

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

the class MapUnionSumAggregation method generateAggregation.

private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType, MapType outputType) {
    DynamicClassLoader classLoader = new DynamicClassLoader(MapUnionSumAggregation.class.getClassLoader());
    List<Type> inputTypes = ImmutableList.of(outputType);
    MapUnionSumStateSerializer stateSerializer = new MapUnionSumStateSerializer(outputType);
    Type intermediateType = stateSerializer.getSerializedType();
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(outputType), INPUT_FUNCTION.bindTo(keyType).bindTo(valueType), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor(MapUnionSumState.class, stateSerializer, new MapUnionSumStateFactory(keyType, valueType))), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, false, factory);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) MapType(com.facebook.presto.common.type.MapType) Type(com.facebook.presto.common.type.Type) MapUnionSumStateFactory(com.facebook.presto.operator.aggregation.state.MapUnionSumStateFactory) MapUnionSumStateSerializer(com.facebook.presto.operator.aggregation.state.MapUnionSumStateSerializer) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 MapType (com.facebook.presto.common.type.MapType)1 Type (com.facebook.presto.common.type.Type)1 AccumulatorStateDescriptor (com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)1 MapUnionSumStateFactory (com.facebook.presto.operator.aggregation.state.MapUnionSumStateFactory)1 MapUnionSumStateSerializer (com.facebook.presto.operator.aggregation.state.MapUnionSumStateSerializer)1