Search in sources :

Example 6 with CombineFunction

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());
}
Also used : TDigest(io.airlift.stats.TDigest) CombineFunction(io.trino.spi.function.CombineFunction)

Example 7 with CombineFunction

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());
    }
}
Also used : TDigest(io.airlift.stats.TDigest) CombineFunction(io.trino.spi.function.CombineFunction)

Example 8 with CombineFunction

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

Aggregations

CombineFunction (io.trino.spi.function.CombineFunction)8 TDigest (io.airlift.stats.TDigest)3 HyperLogLog (io.airlift.stats.cardinality.HyperLogLog)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Strings.emptyToNull (com.google.common.base.Strings.emptyToNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)1 MoreCollectors (com.google.common.collect.MoreCollectors)1 Logger (io.airlift.log.Logger)1 QuantileDigest (io.airlift.stats.QuantileDigest)1 Signature (io.trino.metadata.Signature)1 ParametricFunctionHelpers.signatureWithName (io.trino.operator.ParametricFunctionHelpers.signatureWithName)1 ParametricImplementationsGroup (io.trino.operator.ParametricImplementationsGroup)1 Parser.parseImplementation (io.trino.operator.aggregation.AggregationImplementation.Parser.parseImplementation)1 FunctionsParserHelper (io.trino.operator.annotations.FunctionsParserHelper)1 FunctionsParserHelper.parseDescription (io.trino.operator.annotations.FunctionsParserHelper.parseDescription)1 AccumulatorState (io.trino.spi.function.AccumulatorState)1 AggregationFunction (io.trino.spi.function.AggregationFunction)1