Search in sources :

Example 1 with MultiKeyValuePairStateSerializer

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

the class MultimapAggregationFunction method generateAggregation.

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

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 MultiKeyValuePairStateSerializer (com.facebook.presto.operator.aggregation.state.MultiKeyValuePairStateSerializer)1 MultiKeyValuePairsStateFactory (com.facebook.presto.operator.aggregation.state.MultiKeyValuePairsStateFactory)1 Type (com.facebook.presto.spi.type.Type)1 ArrayType (com.facebook.presto.type.ArrayType)1 MapType (com.facebook.presto.type.MapType)1