Search in sources :

Example 1 with QuantileDigestType

use of io.prestosql.spi.type.QuantileDigestType in project hetu-core by openlookeng.

the class QuantileDigestAggregationFunction method generateAggregation.

private static InternalAggregationFunction generateAggregation(Type valueType, QuantileDigestType outputType, int arity) {
    DynamicClassLoader classLoader = new DynamicClassLoader(QuantileDigestAggregationFunction.class.getClassLoader());
    List<Type> inputTypes = getInputTypes(valueType, arity);
    QuantileDigestStateSerializer stateSerializer = new QuantileDigestStateSerializer(valueType);
    Type intermediateType = stateSerializer.getSerializedType();
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(inputTypes), getMethodHandle(valueType, arity), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(QuantileDigestState.class, stateSerializer, new QuantileDigestStateFactory())), outputType);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory);
}
Also used : DynamicClassLoader(io.airlift.bytecode.DynamicClassLoader) QuantileDigestType(io.prestosql.spi.type.QuantileDigestType) Type(io.prestosql.spi.type.Type) QuantileDigestStateSerializer(io.prestosql.operator.aggregation.state.QuantileDigestStateSerializer) AccumulatorStateDescriptor(io.prestosql.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) QuantileDigestStateFactory(io.prestosql.operator.aggregation.state.QuantileDigestStateFactory)

Example 2 with QuantileDigestType

use of io.prestosql.spi.type.QuantileDigestType in project hetu-core by openlookeng.

the class MergeQuantileDigestFunction method specialize.

@Override
public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
    Type valueType = boundVariables.getTypeVariable("T");
    QuantileDigestType outputType = (QuantileDigestType) functionAndTypeManager.getParameterizedType(StandardTypes.QDIGEST, ImmutableList.of(TypeSignatureParameter.of(valueType.getTypeSignature())));
    return generateAggregation(valueType, outputType);
}
Also used : QuantileDigestType(io.prestosql.spi.type.QuantileDigestType) Type(io.prestosql.spi.type.Type) QuantileDigestType(io.prestosql.spi.type.QuantileDigestType)

Example 3 with QuantileDigestType

use of io.prestosql.spi.type.QuantileDigestType in project hetu-core by openlookeng.

the class MergeQuantileDigestFunction method generateAggregation.

private static InternalAggregationFunction generateAggregation(Type valueType, QuantileDigestType type) {
    DynamicClassLoader classLoader = new DynamicClassLoader(MapAggregationFunction.class.getClassLoader());
    QuantileDigestStateSerializer stateSerializer = new QuantileDigestStateSerializer(valueType);
    Type intermediateType = stateSerializer.getSerializedType();
    AggregationMetadata metadata = new AggregationMetadata(generateAggregationName(NAME, type.getTypeSignature(), ImmutableList.of(type.getTypeSignature())), createInputParameterMetadata(type), INPUT_FUNCTION.bindTo(type), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor(QuantileDigestState.class, stateSerializer, new QuantileDigestStateFactory())), type);
    GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader);
    return new InternalAggregationFunction(NAME, ImmutableList.of(type), ImmutableList.of(intermediateType), type, true, true, factory);
}
Also used : DynamicClassLoader(io.airlift.bytecode.DynamicClassLoader) QuantileDigestStateSerializer(io.prestosql.operator.aggregation.state.QuantileDigestStateSerializer) QuantileDigestType(io.prestosql.spi.type.QuantileDigestType) Type(io.prestosql.spi.type.Type) AccumulatorStateDescriptor(io.prestosql.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor) QuantileDigestStateFactory(io.prestosql.operator.aggregation.state.QuantileDigestStateFactory)

Example 4 with QuantileDigestType

use of io.prestosql.spi.type.QuantileDigestType in project hetu-core by openlookeng.

the class QuantileDigestAggregationFunction method specialize.

@Override
public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, FunctionAndTypeManager functionAndTypeManager) {
    Type valueType = boundVariables.getTypeVariable("V");
    QuantileDigestType outputType = (QuantileDigestType) functionAndTypeManager.getParameterizedType(StandardTypes.QDIGEST, ImmutableList.of(TypeSignatureParameter.of(valueType.getTypeSignature())));
    return generateAggregation(valueType, outputType, arity);
}
Also used : QuantileDigestType(io.prestosql.spi.type.QuantileDigestType) Type(io.prestosql.spi.type.Type) QuantileDigestType(io.prestosql.spi.type.QuantileDigestType)

Aggregations

QuantileDigestType (io.prestosql.spi.type.QuantileDigestType)4 Type (io.prestosql.spi.type.Type)4 DynamicClassLoader (io.airlift.bytecode.DynamicClassLoader)2 AccumulatorStateDescriptor (io.prestosql.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor)2 QuantileDigestStateFactory (io.prestosql.operator.aggregation.state.QuantileDigestStateFactory)2 QuantileDigestStateSerializer (io.prestosql.operator.aggregation.state.QuantileDigestStateSerializer)2