Search in sources :

Example 6 with InputFunction

use of io.trino.spi.function.InputFunction in project trino by trinodb.

the class ApproximateSetAggregation method input.

@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.DOUBLE) double value) {
    HyperLogLog hll = getOrCreateHyperLogLog(state);
    state.addMemoryUsage(-hll.estimatedInMemorySize());
    hll.add(Double.doubleToLongBits(value));
    state.addMemoryUsage(hll.estimatedInMemorySize());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) InputFunction(io.trino.spi.function.InputFunction)

Example 7 with InputFunction

use of io.trino.spi.function.InputFunction in project trino by trinodb.

the class ApproximateSetAggregation method input.

@InputFunction
@LiteralParameters("x")
public static void input(@AggregationState HyperLogLogState state, @SqlType("varchar(x)") Slice value) {
    HyperLogLog hll = getOrCreateHyperLogLog(state);
    state.addMemoryUsage(-hll.estimatedInMemorySize());
    hll.add(value);
    state.addMemoryUsage(hll.estimatedInMemorySize());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) LiteralParameters(io.trino.spi.function.LiteralParameters) InputFunction(io.trino.spi.function.InputFunction)

Example 8 with InputFunction

use of io.trino.spi.function.InputFunction in project trino by trinodb.

the class ApproximateSetGenericAggregation method input.

@InputFunction
@TypeParameter("T")
public static void input(@OperatorDependency(operator = XX_HASH_64, argumentTypes = "T", convention = @Convention(arguments = NEVER_NULL, result = FAIL_ON_NULL)) MethodHandle methodHandle, @AggregationState HyperLogLogState state, @SqlType("T") long value) {
    HyperLogLog hll = getOrCreateHyperLogLog(state);
    state.addMemoryUsage(-hll.estimatedInMemorySize());
    long hash;
    try {
        hash = (long) methodHandle.invoke(value);
    } catch (Throwable t) {
        throw internalError(t);
    }
    hll.addHash(hash);
    state.addMemoryUsage(hll.estimatedInMemorySize());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) TypeParameter(io.trino.spi.function.TypeParameter) InputFunction(io.trino.spi.function.InputFunction)

Example 9 with InputFunction

use of io.trino.spi.function.InputFunction in project trino by trinodb.

the class ApproximateSetGenericAggregation method input.

@InputFunction
@TypeParameter("T")
public static void input(@OperatorDependency(operator = XX_HASH_64, argumentTypes = "T", convention = @Convention(arguments = NEVER_NULL, result = FAIL_ON_NULL)) MethodHandle methodHandle, @AggregationState HyperLogLogState state, @SqlType("T") double value) {
    HyperLogLog hll = getOrCreateHyperLogLog(state);
    state.addMemoryUsage(-hll.estimatedInMemorySize());
    long hash;
    try {
        hash = (long) methodHandle.invoke(value);
    } catch (Throwable t) {
        throw internalError(t);
    }
    hll.addHash(hash);
    state.addMemoryUsage(hll.estimatedInMemorySize());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) TypeParameter(io.trino.spi.function.TypeParameter) InputFunction(io.trino.spi.function.InputFunction)

Example 10 with InputFunction

use of io.trino.spi.function.InputFunction in project trino by trinodb.

the class ApproximateDoublePercentileArrayAggregations method weightedInput.

@InputFunction
public static void weightedInput(@AggregationState TDigestAndPercentileArrayState state, @SqlType(StandardTypes.DOUBLE) double value, @SqlType(StandardTypes.DOUBLE) double weight, @SqlType("array(double)") Block percentilesArrayBlock) {
    verifyWeight(weight);
    initializePercentilesArray(state, percentilesArrayBlock);
    initializeDigest(state);
    TDigest digest = state.getDigest();
    state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
    digest.add(value, weight);
    state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
}
Also used : TDigest(io.airlift.stats.TDigest) InputFunction(io.trino.spi.function.InputFunction)

Aggregations

InputFunction (io.trino.spi.function.InputFunction)20 HyperLogLog (io.airlift.stats.cardinality.HyperLogLog)11 TDigest (io.airlift.stats.TDigest)6 TypeParameter (io.trino.spi.function.TypeParameter)6 Envelope (com.esri.core.geometry.Envelope)1 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 Rectangle (io.trino.geospatial.Rectangle)1 GeometrySerde.deserializeEnvelope (io.trino.geospatial.serde.GeometrySerde.deserializeEnvelope)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