use of io.trino.spi.function.InputFunction in project trino by trinodb.
the class ApproximateCountDistinctAggregation 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, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
long hash;
try {
hash = (long) methodHandle.invokeExact(value);
} catch (Throwable t) {
throw internalError(t);
}
hll.addHash(hash);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
use of io.trino.spi.function.InputFunction in project trino by trinodb.
the class ApproximateDoublePercentileAggregations method input.
@InputFunction
public static void input(@AggregationState TDigestAndPercentileState state, @SqlType(StandardTypes.DOUBLE) double value, @SqlType(StandardTypes.DOUBLE) double percentile) {
TDigest digest = state.getDigest();
if (digest == null) {
digest = new TDigest();
state.setDigest(digest);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
}
state.addMemoryUsage(-digest.estimatedInMemorySizeInBytes());
digest.add(value);
state.addMemoryUsage(digest.estimatedInMemorySizeInBytes());
// use last percentile
state.setPercentile(percentile);
}
use of io.trino.spi.function.InputFunction in project trino by trinodb.
the class ApproximateDoublePercentileAggregations method weightedInput.
@InputFunction
public static void weightedInput(@AggregationState TDigestAndPercentileState state, @SqlType(StandardTypes.DOUBLE) double value, @SqlType(StandardTypes.DOUBLE) double weight, @SqlType(StandardTypes.DOUBLE) double percentile) {
verifyWeight(weight);
TDigest digest = state.getDigest();
if (digest == null) {
digest = new TDigest();
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 io.trino.spi.function.InputFunction in project trino by trinodb.
the class ApproximateCountDistinctAggregation 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, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
state.addMemoryUsage(-hll.estimatedInMemorySize());
long hash;
try {
hash = (long) methodHandle.invokeExact(value);
} catch (Throwable t) {
throw internalError(t);
}
hll.addHash(hash);
state.addMemoryUsage(hll.estimatedInMemorySize());
}
use of io.trino.spi.function.InputFunction in project trino by trinodb.
the class ApproximateCountDistinctAggregation 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") Object value, @SqlType(StandardTypes.DOUBLE) double maxStandardError) {
HyperLogLog hll = getOrCreateHyperLogLog(state, maxStandardError);
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());
}
Aggregations