use of com.facebook.airlift.stats.QuantileDigest in project presto by prestodb.
the class TestQuantileDigestFunctions method testGetValueAtQuantileBelowZero.
@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "Quantile should be within bounds \\[0, 1\\], was: -\\d+\\.\\d+")
public void testGetValueAtQuantileBelowZero() {
QuantileDigest qdigest = new QuantileDigest(1);
functionAssertions.assertFunction(format("value_at_quantile(CAST(X'%s' AS qdigest(bigint)), -0.2)", toHexString(qdigest)), BIGINT, null);
}
use of com.facebook.airlift.stats.QuantileDigest in project presto by prestodb.
the class TestQuantileDigestFunctions method testQuantileAtValueBigintWithEmptyDigest.
@Test
public void testQuantileAtValueBigintWithEmptyDigest() {
QuantileDigest qdigest = new QuantileDigest(1);
functionAssertions.assertFunction(format("quantile_at_value(CAST(X'%s' AS qdigest(bigint)), 5)", toHexString(qdigest)), DOUBLE, null);
}
use of com.facebook.airlift.stats.QuantileDigest in project presto by prestodb.
the class TestQuantileDigestFunctions method testQuantileAtValueBigint.
@Test
public void testQuantileAtValueBigint() {
QuantileDigest qdigest = new QuantileDigest(1);
addAll(qdigest, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
functionAssertions.assertFunction(format("quantile_at_value(CAST(X'%s' AS qdigest(bigint)), 20)", toHexString(qdigest)), DOUBLE, null);
functionAssertions.assertFunction(format("quantile_at_value(CAST(X'%s' AS qdigest(bigint)), 6)", toHexString(qdigest)), DOUBLE, 0.6);
functionAssertions.assertFunction(format("quantile_at_value(CAST(X'%s' AS qdigest(bigint)), -1)", toHexString(qdigest)), DOUBLE, null);
}
use of com.facebook.airlift.stats.QuantileDigest in project presto by prestodb.
the class QuantileDigestFunctions method scaleQuantileDigest.
private static Slice scaleQuantileDigest(Slice input, double scale) {
checkCondition(scale > 0, INVALID_FUNCTION_ARGUMENT, "Scale factor should be positive.");
QuantileDigest digest = new QuantileDigest(input);
digest.scale(scale);
return digest.serialize();
}
Aggregations