Search in sources :

Example 1 with AccumulatorState

use of com.facebook.presto.spi.function.AccumulatorState in project presto by prestodb.

the class AggregationCompiler method getStateClasses.

private static Set<Class<?>> getStateClasses(Class<?> clazz) {
    ImmutableSet.Builder<Class<?>> builder = ImmutableSet.builder();
    for (Method inputFunction : findPublicStaticMethodsWithAnnotation(clazz, InputFunction.class)) {
        checkArgument(inputFunction.getParameterTypes().length > 0, "Input function has no parameters");
        Class<?> stateClass = findAggregationStateParamType(inputFunction);
        checkArgument(AccumulatorState.class.isAssignableFrom(stateClass), "stateClass is not a subclass of AccumulatorState");
        builder.add(stateClass);
    }
    ImmutableSet<Class<?>> stateClasses = builder.build();
    checkArgument(!stateClasses.isEmpty(), "No input functions found");
    return stateClasses;
}
Also used : AccumulatorState(com.facebook.presto.spi.function.AccumulatorState) ImmutableSet(com.google.common.collect.ImmutableSet) Method(java.lang.reflect.Method)

Aggregations

AccumulatorState (com.facebook.presto.spi.function.AccumulatorState)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Method (java.lang.reflect.Method)1