Search in sources :

Example 1 with CombineFunction

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());
}
Also used : QuantileDigest(io.airlift.stats.QuantileDigest) CombineFunction(com.facebook.presto.spi.function.CombineFunction)

Example 2 with CombineFunction

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());
    }
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) CombineFunction(com.facebook.presto.spi.function.CombineFunction)

Example 3 with CombineFunction

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());
    }
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) CombineFunction(com.facebook.presto.spi.function.CombineFunction)

Example 4 with CombineFunction

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());
}
Also used : QuantileDigest(io.airlift.stats.QuantileDigest) CombineFunction(com.facebook.presto.spi.function.CombineFunction)

Aggregations

CombineFunction (com.facebook.presto.spi.function.CombineFunction)4 QuantileDigest (io.airlift.stats.QuantileDigest)2 HyperLogLog (io.airlift.stats.cardinality.HyperLogLog)2