use of io.trino.spi.function.CombineFunction in project trino by trinodb.
the class ApproximateDoublePercentileAggregations method combine.
@CombineFunction
public static void combine(@AggregationState TDigestAndPercentileState state, TDigestAndPercentileState otherState) {
TDigest input = otherState.getDigest();
TDigest previous = state.getDigest();
if (previous == null) {
state.setDigest(input);
state.addMemoryUsage(input.estimatedInMemorySizeInBytes());
} else {
state.addMemoryUsage(-previous.estimatedInMemorySizeInBytes());
previous.mergeWith(input);
state.addMemoryUsage(previous.estimatedInMemorySizeInBytes());
}
state.setPercentile(otherState.getPercentile());
}
use of io.trino.spi.function.CombineFunction in project trino by trinodb.
the class TDigestAggregationFunction method combine.
@CombineFunction
public static void combine(@AggregationState TDigestState state, @AggregationState TDigestState otherState) {
TDigest input = otherState.getTDigest();
if (input == null) {
return;
}
TDigest previous = state.getTDigest();
if (previous == null) {
state.setTDigest(input);
state.addMemoryUsage(input.estimatedInMemorySizeInBytes());
} else {
state.addMemoryUsage(-previous.estimatedInMemorySizeInBytes());
previous.mergeWith(input);
state.addMemoryUsage(previous.estimatedInMemorySizeInBytes());
}
}
use of io.trino.spi.function.CombineFunction in project trino by trinodb.
the class LegacyApproximateLongPercentileAggregations method combine.
@CombineFunction
public static void combine(@AggregationState QuantileDigestAndPercentileState state, QuantileDigestAndPercentileState otherState) {
QuantileDigest input = otherState.getDigest();
QuantileDigest previous = state.getDigest();
if (previous == null) {
state.setDigest(input);
state.addMemoryUsage(input.estimatedInMemorySizeInBytes());
} else {
state.addMemoryUsage(-previous.estimatedInMemorySizeInBytes());
previous.merge(input);
state.addMemoryUsage(previous.estimatedInMemorySizeInBytes());
}
state.setPercentile(otherState.getPercentile());
}
Aggregations