Search in sources :

Example 6 with AccumulatorStateDescriptor

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);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) DoubleState(com.facebook.presto.operator.aggregation.state.DoubleState) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) ParameterMetadata(com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata) LongState(com.facebook.presto.operator.aggregation.state.LongState)

Example 7 with AccumulatorStateDescriptor

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);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) Type(com.facebook.presto.common.type.Type) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) StatisticalDigestStateSerializer(com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer)

Example 8 with AccumulatorStateDescriptor

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);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) SetAggregationStateFactory(com.facebook.presto.operator.aggregation.state.SetAggregationStateFactory) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) GenericAccumulatorFactoryBinder(com.facebook.presto.operator.aggregation.GenericAccumulatorFactoryBinder) InternalAggregationFunction(com.facebook.presto.operator.aggregation.InternalAggregationFunction) ParameterMetadata(com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata) ArrayType(com.facebook.presto.common.type.ArrayType) ArrayType(com.facebook.presto.common.type.ArrayType) Type(com.facebook.presto.common.type.Type) SetAggregationState(com.facebook.presto.operator.aggregation.state.SetAggregationState) AggregationMetadata(com.facebook.presto.operator.aggregation.AggregationMetadata)

Example 9 with AccumulatorStateDescriptor

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);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) Type(com.facebook.presto.common.type.Type) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) StatisticalDigestStateSerializer(com.facebook.presto.operator.aggregation.state.StatisticalDigestStateSerializer)

Example 10 with AccumulatorStateDescriptor

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);
}
Also used : DynamicClassLoader(com.facebook.presto.bytecode.DynamicClassLoader) NullableLongState(com.facebook.presto.operator.aggregation.state.NullableLongState) Type(com.facebook.presto.common.type.Type) AccumulatorStateDescriptor(com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)

Aggregations

AccumulatorStateDescriptor (com.facebook.presto.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)23 DynamicClassLoader (com.facebook.presto.bytecode.DynamicClassLoader)22 Type (com.facebook.presto.common.type.Type)20 MethodHandle (java.lang.invoke.MethodHandle)9 ArrayType (com.facebook.presto.common.type.ArrayType)7 AggregationMetadata (com.facebook.presto.operator.aggregation.AggregationMetadata)7 ParameterMetadata (com.facebook.presto.operator.aggregation.AggregationMetadata.ParameterMetadata)7 GenericAccumulatorFactoryBinder (com.facebook.presto.operator.aggregation.GenericAccumulatorFactoryBinder)7 InternalAggregationFunction (com.facebook.presto.operator.aggregation.InternalAggregationFunction)7 MapType (com.facebook.presto.common.type.MapType)3 CallSiteBinder (com.facebook.presto.bytecode.CallSiteBinder)2 ClassDefinition (com.facebook.presto.bytecode.ClassDefinition)2 OperatorType (com.facebook.presto.common.function.OperatorType)2 DecimalType (com.facebook.presto.common.type.DecimalType)2 BlockPositionStateSerializer (com.facebook.presto.operator.aggregation.state.BlockPositionStateSerializer)2 KeyValuePairStateSerializer (com.facebook.presto.operator.aggregation.state.KeyValuePairStateSerializer)2 KeyValuePairsStateFactory (com.facebook.presto.operator.aggregation.state.KeyValuePairsStateFactory)2 LongState (com.facebook.presto.operator.aggregation.state.LongState)2 NullableDoubleState (com.facebook.presto.operator.aggregation.state.NullableDoubleState)2 SetAggregationState (com.facebook.presto.operator.aggregation.state.SetAggregationState)2