use of io.trino.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project trino by trinodb.
the class MapUnionAggregation method specialize.
@Override
public AggregationMetadata specialize(BoundSignature boundSignature) {
MapType outputType = (MapType) boundSignature.getReturnType();
Type keyType = outputType.getKeyType();
BlockPositionEqual keyEqual = blockTypeOperators.getEqualOperator(keyType);
BlockPositionHashCode keyHashCode = blockTypeOperators.getHashCodeOperator(keyType);
Type valueType = outputType.getValueType();
KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(outputType, keyEqual, keyHashCode);
MethodHandle inputFunction = MethodHandles.insertArguments(INPUT_FUNCTION, 0, keyType, keyEqual, keyHashCode, valueType);
inputFunction = normalizeInputMethod(inputFunction, boundSignature, STATE, INPUT_CHANNEL);
return new AggregationMetadata(inputFunction, Optional.empty(), Optional.of(COMBINE_FUNCTION), OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor<>(KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType))));
}
use of io.trino.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project trino by trinodb.
the class MergeQuantileDigestFunction method specialize.
@Override
public AggregationMetadata specialize(BoundSignature boundSignature) {
QuantileDigestType outputType = (QuantileDigestType) boundSignature.getReturnType();
Type valueType = outputType.getValueType();
QuantileDigestStateSerializer stateSerializer = new QuantileDigestStateSerializer(valueType);
return new AggregationMetadata(INPUT_FUNCTION.bindTo(outputType), Optional.empty(), Optional.of(COMBINE_FUNCTION), OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor<>(QuantileDigestState.class, stateSerializer, new QuantileDigestStateFactory())));
}
use of io.trino.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project trino by trinodb.
the class MapAggregationFunction method specialize.
@Override
public AggregationMetadata specialize(BoundSignature boundSignature) {
MapType outputType = (MapType) boundSignature.getReturnType();
Type keyType = outputType.getKeyType();
BlockPositionEqual keyEqual = blockTypeOperators.getEqualOperator(keyType);
BlockPositionHashCode keyHashCode = blockTypeOperators.getHashCodeOperator(keyType);
Type valueType = outputType.getValueType();
KeyValuePairStateSerializer stateSerializer = new KeyValuePairStateSerializer(outputType, keyEqual, keyHashCode);
return new AggregationMetadata(MethodHandles.insertArguments(INPUT_FUNCTION, 0, keyType, keyEqual, keyHashCode, valueType), Optional.empty(), Optional.of(COMBINE_FUNCTION), OUTPUT_FUNCTION, ImmutableList.of(new AccumulatorStateDescriptor<>(KeyValuePairsState.class, stateSerializer, new KeyValuePairsStateFactory(keyType, valueType))));
}
use of io.trino.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project trino by trinodb.
the class DecimalAverageAggregation method specialize.
@Override
public AggregationMetadata specialize(BoundSignature boundSignature) {
Type type = getOnlyElement(boundSignature.getArgumentTypes());
checkArgument(type instanceof DecimalType, "type must be Decimal");
MethodHandle inputFunction;
MethodHandle outputFunction;
Class<LongDecimalWithOverflowAndLongState> stateInterface = LongDecimalWithOverflowAndLongState.class;
LongDecimalWithOverflowAndLongStateSerializer stateSerializer = new LongDecimalWithOverflowAndLongStateSerializer();
if (((DecimalType) type).isShort()) {
inputFunction = SHORT_DECIMAL_INPUT_FUNCTION;
outputFunction = SHORT_DECIMAL_OUTPUT_FUNCTION;
} else {
inputFunction = LONG_DECIMAL_INPUT_FUNCTION;
outputFunction = LONG_DECIMAL_OUTPUT_FUNCTION;
}
outputFunction = outputFunction.bindTo(type);
return new AggregationMetadata(inputFunction, Optional.empty(), Optional.of(COMBINE_FUNCTION), outputFunction, ImmutableList.of(new AccumulatorStateDescriptor<>(stateInterface, stateSerializer, new LongDecimalWithOverflowAndLongStateFactory())));
}
use of io.trino.operator.aggregation.AggregationMetadata.AccumulatorStateDescriptor in project trino by trinodb.
the class ArrayAggregationFunction method specialize.
@Override
public AggregationMetadata specialize(BoundSignature boundSignature) {
Type type = boundSignature.getArgumentTypes().get(0);
ArrayAggregationStateSerializer stateSerializer = new ArrayAggregationStateSerializer(type);
ArrayAggregationStateFactory stateFactory = new ArrayAggregationStateFactory(type);
MethodHandle inputFunction = INPUT_FUNCTION.bindTo(type);
MethodHandle combineFunction = COMBINE_FUNCTION.bindTo(type);
MethodHandle outputFunction = OUTPUT_FUNCTION.bindTo(type);
return new AggregationMetadata(inputFunction, Optional.empty(), Optional.of(combineFunction), outputFunction, ImmutableList.of(new AccumulatorStateDescriptor<>(ArrayAggregationState.class, stateSerializer, stateFactory)));
}
Aggregations