Search in sources :

Example 1 with KeyValuePairsStateFactory

use of io.prestosql.operator.aggregation.state.KeyValuePairsStateFactory in project hetu-core by openlookeng.

the class MapAggregationFunction method generateAggregation.

private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType, MapType outputType) {
    DynamicClassLoader classLoader = new DynamicClassLoader(MapAggregationFunction.class.getClassLoader());
    List<Type> inputTypes = ImmutableList.of(keyType, valueType);
    KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(outputType);
    Type intermediateType = stateSerializer.getSerializedType();
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(keyType, valueType), INPUT_FUNCTION.bindTo(keyType).bindTo(valueType), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor(KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType))), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory);
}
Also used : DynamicClassLoader(io.airlift.bytecode.DynamicClassLoader) MapType(io.prestosql.spi.type.MapType) Type(io.prestosql.spi.type.Type) KeyValuePairStateSerializer(io.prestosql.operator.aggregation.state.KeyValuePairStateSerializer) AccumulatorStateDescriptor(io.prestosql.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) KeyValuePairsStateFactory(io.prestosql.operator.aggregation.state.KeyValuePairsStateFactory)

Example 2 with KeyValuePairsStateFactory

use of io.prestosql.operator.aggregation.state.KeyValuePairsStateFactory in project hetu-core by openlookeng.

the class MapUnionAggregation method generateAggregation.

private static InternalAggregationFunction generateAggregation(Type keyType, Type valueType, MapType outputType) {
    DynamicClassLoader classLoader = new DynamicClassLoader(MapUnionAggregation.class.getClassLoader());
    List<Type> inputTypes = ImmutableList.of(outputType);
    KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(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(KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType))), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, false, factory);
}
Also used : DynamicClassLoader(io.airlift.bytecode.DynamicClassLoader) MapType(io.prestosql.spi.type.MapType) Type(io.prestosql.spi.type.Type) KeyValuePairStateSerializer(io.prestosql.operator.aggregation.state.KeyValuePairStateSerializer) AccumulatorStateDescriptor(io.prestosql.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) KeyValuePairsStateFactory(io.prestosql.operator.aggregation.state.KeyValuePairsStateFactory)

Aggregations

DynamicClassLoader (io.airlift.bytecode.DynamicClassLoader)2 AccumulatorStateDescriptor (io.prestosql.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)2 KeyValuePairStateSerializer (io.prestosql.operator.aggregation.state.KeyValuePairStateSerializer)2 KeyValuePairsStateFactory (io.prestosql.operator.aggregation.state.KeyValuePairsStateFactory)2 MapType (io.prestosql.spi.type.MapType)2 Type (io.prestosql.spi.type.Type)2