use of com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project presto by prestodb.
the class RealAverageAggregation method specialize.
@Override
public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
DynamicClassLoader classLoader = new DynamicClassLoader(AverageAggregations.class.getClassLoader());
Class<? extends AccumulatorState> longStateInterface = LongState.class;
Class<? extends AccumulatorState> doubleStateInterface = DoubleState.class;
AccumulatorStateSerializer<?> longStateSerializer = StateCompiler.generateStateSerializer(longStateInterface, classLoader);
AccumulatorStateSerializer<?> doubleStateSerializer = StateCompiler.generateStateSerializer(doubleStateInterface, classLoader);
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, parseTypeSignature(StandardTypes.REAL), ImmutableList.of(parseTypeSignature(StandardTypes.REAL))), ImmutableList.of(new ParameterMetadata(STATE), new ParameterMetadata(STATE), new ParameterMetadata(INPUT_CHANNEL, REAL)), INPUT_FUNCTION, COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor(longStateInterface, longStateSerializer, StateCompiler.generateStateFactory(longStateInterface, classLoader)), new AccumulatorStateDescriptor(doubleStateInterface, doubleStateSerializer, StateCompiler.generateStateFactory(doubleStateInterface, classLoader))), REAL);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, ImmutableList.of(REAL), ImmutableList.of(longStateSerializer.getSerializedType(), doubleStateSerializer.getSerializedType()), REAL, true, false, factory);
}
use of com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project presto by prestodb.
the class StatisticalDigestAggregationFunction method generateAggregation.
private InternalAggregationFunction generateAggregation(String name, Type valueType, Type outputType, int arity) {
DynamicClassLoader classLoader = new DynamicClassLoader(StatisticalDigestAggregationFunction.class.getClassLoader());
List<Type> inputTypes = getInputTypes(valueType, arity);
StatisticalDigestStateSerializer stateSerializer = new StatisticalDigestStateSerializer();
Type intermediateType = stateSerializer.getSerializedType();
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(name, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(inputTypes), getInputMethodHandle(valueType, arity), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(StatisticalDigestState.class, stateSerializer, factory)), outputType);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(name, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory);
}
use of com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor 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.AggregationMetadata.AccumulatorStateDescriptor in project presto by prestodb.
the class MergeStatisticalDigestFunction method generateAggregation.
private InternalAggregationFunction generateAggregation(Type type) {
DynamicClassLoader classLoader = new DynamicClassLoader(MapAggregationFunction.class.getClassLoader());
StatisticalDigestStateSerializer stateSerializer = new StatisticalDigestStateSerializer();
Type intermediateType = stateSerializer.getSerializedType();
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(name, type.getTypeSignature(), ImmutableList.of(type.getTypeSignature())), createInputParameterMetadata(type), getInputFunction().bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(StatisticalDigestState.class, stateSerializer, factory)), type);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(name, ImmutableList.of(type), ImmutableList.of(intermediateType), type, true, true, factory);
}
use of com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project presto by prestodb.
the class ChecksumAggregationFunction method generateAggregation.
private static InternalAggregationFunction generateAggregation(Type type) {
DynamicClassLoader classLoader = new DynamicClassLoader(ChecksumAggregationFunction.class.getClassLoader());
List<Type> inputTypes = ImmutableList.of(type);
AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, type.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(type), INPUT_FUNCTION.bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor(NullableLongState.class, StateCompiler.generateStateSerializer(NullableLongState.class, classLoader), StateCompiler.generateStateFactory(NullableLongState.class, classLoader))), VARBINARY);
GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(BIGINT), VARBINARY, true, false, factory);
}
Aggregations