use of com.facebook.presto.operator.aggregation.state.SetAggregationStateFactory in project presto by prestodb.
the class SetUnionFunction method specialize.
@Override
public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
Type elementType = boundVariables.getTypeVariable("T");
ArrayType arrayType = (ArrayType) functionAndTypeManager.getParameterizedType(StandardTypes.ARRAY, ImmutableList.of(TypeSignatureParameter.of(elementType.getTypeSignature())));
DynamicClassLoader classLoader = new DynamicClassLoader(SetUnionFunction.class.getClassLoader());
AccumulatorStateSerializer<?> stateSerializer = new SetAggregationStateSerializer(arrayType);
AccumulatorStateFactory<?> stateFactory = new SetAggregationStateFactory(elementType);
Class<? extends AccumulatorState> stateInterface = SetAggregationState.class;
List<ParameterMetadata> inputParameterMetadata = ImmutableList.of(new ParameterMetadata(STATE), new ParameterMetadata(NULLABLE_BLOCK_INPUT_CHANNEL, elementType), new ParameterMetadata(BLOCK_INDEX));
AggregationMetadata metadata = new AggregationMetadata(AggregationUtils.generateAggregationName(NAME, arrayType.getTypeSignature(), ImmutableList.of(elementType.getTypeSignature())), inputParameterMetadata, INPUT_FUNCTION.bindTo(elementType).bindTo(arrayType), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor(stateInterface, stateSerializer, stateFactory)), arrayType);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, ImmutableList.of(elementType), ImmutableList.of(stateSerializer.getSerializedType()), arrayType, true, true, factory);
}
use of com.facebook.presto.operator.aggregation.state.SetAggregationStateFactory in project presto by prestodb.
the class SetAggregationFunction method generateAggregation.
private static InternalAggregationFunction generateAggregation(Type type, ArrayType outputType) {
DynamicClassLoader classLoader = new DynamicClassLoader(SetAggregationFunction.class.getClassLoader());
List<Type> inputTypes = ImmutableList.of(type);
AccumulatorStateSerializer<?> stateSerializer = new SetAggregationStateSerializer(outputType);
AccumulatorStateFactory<?> stateFactory = new SetAggregationStateFactory(type);
Type intermediateType = stateSerializer.getSerializedType();
List<ParameterMetadata> inputParameterMetadata = createInputParameterMetadata(type);
Class<? extends AccumulatorState> stateInterface = SetAggregationState.class;
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), inputParameterMetadata, INPUT_FUNCTION.bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor(stateInterface, stateSerializer, stateFactory)), outputType);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory);
}
Aggregations