Search in sources :

Example 1 with HyperLogLog

use of io.airlift.stats.cardinality.HyperLogLog in project presto by prestodb.

the class CreateHll method createHll.

@ScalarFunction
@SqlType(StandardTypes.HYPER_LOG_LOG)
public static Slice createHll(@SqlType(StandardTypes.BIGINT) long value) {
    HyperLogLog hll = HyperLogLog.newInstance(4096);
    hll.add(value);
    return hll.serialize();
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) ScalarFunction(com.facebook.presto.spi.function.ScalarFunction) SqlType(com.facebook.presto.spi.function.SqlType)

Example 2 with HyperLogLog

use of io.airlift.stats.cardinality.HyperLogLog in project presto by prestodb.

the class MergeHyperLogLogAggregation method input.

@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.HYPER_LOG_LOG) Slice value) {
    HyperLogLog input = HyperLogLog.newInstance(value);
    merge(state, input);
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) InputFunction(com.facebook.presto.spi.function.InputFunction)

Example 3 with HyperLogLog

use of io.airlift.stats.cardinality.HyperLogLog in project presto by prestodb.

the class ApproximateSetAggregation method input.

@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.BIGINT) long value) {
    HyperLogLog hll = getOrCreateHyperLogLog(state);
    state.addMemoryUsage(-hll.estimatedInMemorySize());
    hll.add(value);
    state.addMemoryUsage(hll.estimatedInMemorySize());
}
Also used : HyperLogLog(io.airlift.stats.cardinality.HyperLogLog) InputFunction(com.facebook.presto.spi.function.InputFunction)

Example 4 with HyperLogLog

use of io.airlift.stats.cardinality.HyperLogLog in project presto by prestodb.

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(com.facebook.presto.spi.function.LiteralParameters) InputFunction(com.facebook.presto.spi.function.InputFunction)

Example 5 with HyperLogLog

use of io.airlift.stats.cardinality.HyperLogLog in project presto by prestodb.

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(com.facebook.presto.spi.function.InputFunction)

Aggregations

HyperLogLog (io.airlift.stats.cardinality.HyperLogLog)14 InputFunction (com.facebook.presto.spi.function.InputFunction)6 CombineFunction (com.facebook.presto.spi.function.CombineFunction)2 SqlType (com.facebook.presto.spi.function.SqlType)2 Block (com.facebook.presto.spi.block.Block)1 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)1 BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)1 LiteralParameters (com.facebook.presto.spi.function.LiteralParameters)1 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)1 ScalarOperator (com.facebook.presto.spi.function.ScalarOperator)1