use of com.facebook.presto.spi.type.TypeSignature.parseTypeSignature in project presto by prestodb.
the class AggregationCompiler method generateBindableAggregationFunctions.
public static List<BindableAggregationFunction> generateBindableAggregationFunctions(Class<?> aggregationDefinition) {
AggregationFunction aggregationAnnotation = aggregationDefinition.getAnnotation(AggregationFunction.class);
requireNonNull(aggregationAnnotation, "aggregationAnnotation is null");
DynamicClassLoader classLoader = new DynamicClassLoader(aggregationDefinition.getClassLoader());
ImmutableList.Builder<BindableAggregationFunction> builder = ImmutableList.builder();
for (Class<?> stateClass : getStateClasses(aggregationDefinition)) {
AccumulatorStateSerializer<?> stateSerializer = StateCompiler.generateStateSerializer(stateClass, classLoader);
for (Method outputFunction : getOutputFunctions(aggregationDefinition, stateClass)) {
for (Method inputFunction : getInputFunctions(aggregationDefinition, stateClass)) {
List<LongVariableConstraint> longVariableConstraints = parseLongVariableConstraints(inputFunction);
for (String name : getNames(outputFunction, aggregationAnnotation)) {
List<TypeSignature> inputTypes = getInputTypesSignatures(inputFunction);
TypeSignature outputType = TypeSignature.parseTypeSignature(outputFunction.getAnnotation(OutputFunction.class).value());
builder.add(new BindableAggregationFunction(new Signature(name, FunctionKind.AGGREGATE, // TODO parse constrains from annotations
ImmutableList.of(), longVariableConstraints, outputType, inputTypes, false), getDescription(aggregationDefinition, outputFunction), aggregationAnnotation.decomposable(), aggregationDefinition, stateClass, inputFunction, outputFunction));
}
}
}
}
return builder.build();
}
Aggregations