Search in sources :

Example 1 with MinMaxByNStateSerializer

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

the class AbstractMinMaxByNAggregationFunction method generateAggregation.

protected InternalAggregationFunction generateAggregation(Type valueType, Type keyType) {
    DynamicClassLoader classLoader = new DynamicClassLoader(AbstractMinMaxNAggregationFunction.class.getClassLoader());
    BlockComparator comparator = typeToComparator.apply(keyType);
    List<Type> inputTypes = ImmutableList.of(valueType, keyType, BIGINT);
    MinMaxByNStateSerializer stateSerializer = new MinMaxByNStateSerializer(comparator, keyType, valueType);
    Type intermediateType = stateSerializer.getSerializedType();
    ArrayType outputType = new ArrayType(valueType);
    List<AggregationMetadata.ParameterMetadata> inputParameterMetadata = ImmutableList.of(new AggregationMetadata.ParameterMetadata(STATE), new AggregationMetadata.ParameterMetadata(NULLABLE_BLOCK_INPUT_CHANNEL, valueType), new AggregationMetadata.ParameterMetadata(BLOCK_INPUT_CHANNEL, keyType), new AggregationMetadata.ParameterMetadata(BLOCK_INDEX), new AggregationMetadata.ParameterMetadata(INPUT_CHANNEL, BIGINT));
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(name, valueType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), inputParameterMetadata, INPUT_FUNCTION.bindTo(comparator).bindTo(valueType).bindTo(keyType), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(outputType), MinMaxByNState.class, stateSerializer, new MinMaxByNStateFactory(), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(name, inputTypes, intermediateType, outputType, true, factory);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) MinMaxByNStateSerializer(com.facebook.presto.operator.aggregation.state.MinMaxByNStateSerializer) MinMaxByNStateFactory(com.facebook.presto.operator.aggregation.state.MinMaxByNStateFactory) ArrayType(com.facebook.presto.type.ArrayType) ArrayType(com.facebook.presto.type.ArrayType) Type(com.facebook.presto.spi.type.Type)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 MinMaxByNStateFactory (com.facebook.presto.operator.aggregation.state.MinMaxByNStateFactory)1 MinMaxByNStateSerializer (com.facebook.presto.operator.aggregation.state.MinMaxByNStateSerializer)1 Type (com.facebook.presto.spi.type.Type)1 ArrayType (com.facebook.presto.type.ArrayType)1