use of com.facebook.presto.spi.function.InputFunction in project presto by prestodb.
the class ApproximateLongPercentileAggregations method weightedInput.
@InputFunction
public static void weightedInput(@AggregationState DigestAndPercentileState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.BIGINT) long weight, @SqlType(StandardTypes.DOUBLE) double percentile, @SqlType(StandardTypes.DOUBLE) double accuracy) {
checkWeight(weight);
QuantileDigest digest = state.getDigest();
if (digest == null) {
if (accuracy > 0 && accuracy < 1) {
digest = new QuantileDigest(accuracy);
} else {
throw new IllegalArgumentException("Percentile accuracy must be strictly between 0 and 1");
}
state.setDigest(digest);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
}
state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
digest.add(value, weight);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
// use last percentile
state.setPercentile(percentile);
}
use of com.facebook.presto.spi.function.InputFunction in project presto by prestodb.
the class ApproximateLongPercentileArrayAggregations method input.
@InputFunction
public static void input(@AggregationState DigestAndPercentileArrayState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType("array(double)") Block percentilesArrayBlock) {
initializePercentilesArray(state, percentilesArrayBlock);
initializeDigest(state);
QuantileDigest digest = state.getDigest();
state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
digest.add(value);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
}
use of com.facebook.presto.spi.function.InputFunction in project presto by prestodb.
the class ApproximateCountDistinctAggregations method inputBinary.
@InputFunction
public static void inputBinary(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.VARBINARY) Slice value, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
hll.add(value);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
use of com.facebook.presto.spi.function.InputFunction in project presto by prestodb.
the class ApproximateCountDistinctAggregations method input.
@InputFunction
public static void input(@AggregationState HyperLogLogState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
hll.add(value);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
use of com.facebook.presto.spi.function.InputFunction in project presto by prestodb.
the class ApproximateLongPercentileAggregations method input.
@InputFunction
public static void input(@AggregationState DigestAndPercentileState state, @SqlType(StandardTypes.BIGINT) long value, @SqlType(StandardTypes.DOUBLE) double percentile) {
QuantileDigest digest = state.getDigest();
if (digest == null) {
digest = new QuantileDigest(0.01);
state.setDigest(digest);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
}
state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
digest.add(value);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
// use last percentile
state.setPercentile(percentile);
}
Aggregations