use of com.facebook.presto.spi.function.CombineFunction in project presto by prestodb.
the class ApproximateLongPercentileArrayAggregations method combine.
@CombineFunction
public static void combine(@AggregationState DigestAndPercentileArrayState state, DigestAndPercentileArrayState otherState) {
QuantileDigest otherDigest = otherState.getDigest();
QuantileDigest digest = state.getDigest();
if (digest == null) {
state.setDigest(otherDigest);
state.addMemoryUsage(otherDigest.estimatedInMemorySizeInBytes());
} else {
state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
digest.merge(otherDigest);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
}
state.setPercentiles(otherState.getPercentiles());
}
use of com.facebook.presto.spi.function.CombineFunction in project presto by prestodb.
the class ApproximateSetAggregation method combineState.
@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState) {
HyperLogLog input = otherState.getHyperLogLog();
HyperLogLog previous = state.getHyperLogLog();
if (previous == null) {
state.setHyperLogLog(input);
state.addMemoryUsage(input.estimatedInMemorySize());
} else {
state.addMemoryUsage(-previous.estimatedInMemorySize());
previous.mergeWith(input);
state.addMemoryUsage(previous.estimatedInMemorySize());
}
}
use of com.facebook.presto.spi.function.CombineFunction in project presto by prestodb.
the class ApproximateCountDistinctAggregations method combineState.
@CombineFunction
public static void combineState(@AggregationState HyperLogLogState state, @AggregationState HyperLogLogState otherState) {
HyperLogLog input = otherState.getHyperLogLog();
HyperLogLog previous = state.getHyperLogLog();
if (previous == null) {
state.setHyperLogLog(input);
state.addMemoryUsage(input.estimatedInMemorySize());
} else {
state.addMemoryUsage(-previous.estimatedInMemorySize());
previous.mergeWith(input);
state.addMemoryUsage(previous.estimatedInMemorySize());
}
}
use of com.facebook.presto.spi.function.CombineFunction in project presto by prestodb.
the class ApproximateLongPercentileAggregations method combine.
@CombineFunction
public static void combine(@AggregationState DigestAndPercentileState state, DigestAndPercentileState 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