Search in sources :

Example 1 with ArrayAggregationStateFactory

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

the class ArrayAggregationFunction method generateAggregation.

private static InternalAggregationFunction generateAggregation(Type type, boolean legacyArrayAgg) {
    DynamicClassLoader classLoader = new DynamicClassLoader(ArrayAggregationFunction.class.getClassLoader());
    AccumulatorStateSerializer<?> stateSerializer = new ArrayAggregationStateSerializer(type);
    AccumulatorStateFactory<?> stateFactory = new ArrayAggregationStateFactory();
    List<Type> inputTypes = ImmutableList.of(type);
    Type outputType = new ArrayType(type);
    Type intermediateType = stateSerializer.getSerializedType();
    List<ParameterMetadata> inputParameterMetadata = createInputParameterMetadata(type, legacyArrayAgg);
    MethodHandle inputFunction = INPUT_FUNCTION.bindTo(type);
    MethodHandle combineFunction = COMBINE_FUNCTION.bindTo(type);
    MethodHandle outputFunction = OUTPUT_FUNCTION.bindTo(outputType);
    Class<? extends AccumulatorState> stateInterface = ArrayAggregationState.class;
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, type.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), inputParameterMetadata, inputFunction, combineFunction, outputFunction, stateInterface, stateSerializer, stateFactory, outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(NAME, inputTypes, intermediateType, outputType, true, factory);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) ArrayAggregationStateSerializer(com.facebook.presto.operator.aggregation.state.ArrayAggregationStateSerializer) ParameterMetadata(com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata) ArrayType(com.facebook.presto.type.ArrayType) ArrayType(com.facebook.presto.type.ArrayType) Type(com.facebook.presto.spi.type.Type) ArrayAggregationState(com.facebook.presto.operator.aggregation.state.ArrayAggregationState) ArrayAggregationStateFactory(com.facebook.presto.operator.aggregation.state.ArrayAggregationStateFactory) MethodHandle(java.lang.invoke.MethodHandle)

Aggregations

DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)1 ParameterMetadata (com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata)1 ArrayAggregationState (com.facebook.presto.operator.aggregation.state.ArrayAggregationState)1 ArrayAggregationStateFactory (com.facebook.presto.operator.aggregation.state.ArrayAggregationStateFactory)1 ArrayAggregationStateSerializer (com.facebook.presto.operator.aggregation.state.ArrayAggregationStateSerializer)1 Type (com.facebook.presto.spi.type.Type)1 ArrayType (com.facebook.presto.type.ArrayType)1 MethodHandle (java.lang.invoke.MethodHandle)1