You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2021/03/05 01:23:14 UTC

[datasketches-postgresql] branch master updated: some manual tests to get started

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/datasketches-postgresql.git


The following commit(s) were added to refs/heads/master by this push:
     new 7661cff  some manual tests to get started
7661cff is described below

commit 7661cff5a1c7bde33b27c1472dee1ff5c3ddc674
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Thu Mar 4 17:21:23 2021 -0800

    some manual tests to get started
---
 test/cpc_sketch_test.sql   | 28 ++++++++++++++++++++++++++++
 test/hll_sketch_test.sql   | 28 ++++++++++++++++++++++++++++
 test/kll_sketch_test.sql   | 29 +++++++++++++++++++++++++++++
 test/theta_sketch_test.sql | 33 +++++++++++++++++++++++++++++++++
 4 files changed, 118 insertions(+)

diff --git a/test/cpc_sketch_test.sql b/test/cpc_sketch_test.sql
new file mode 100644
index 0000000..c3fabc6
--- /dev/null
+++ b/test/cpc_sketch_test.sql
@@ -0,0 +1,28 @@
+drop extension if exists datasketches cascade;
+create extension datasketches;
+
+drop table if exists cpc_sketch_test;
+create table cpc_sketch_test(sketch cpc_sketch);
+
+-- default lgk
+insert into cpc_sketch_test
+  select cpc_sketch_build(value)
+  from (values (1), (2), (3), (4), (5)) as t(value)
+;
+
+-- lgk = 8
+insert into cpc_sketch_test
+  select cpc_sketch_build(value, 8)
+  from (values (4), (5), (6), (7), (8)) as t(value)
+;
+
+select cpc_sketch_get_estimate(sketch) from cpc_sketch_test;
+--select cpc_sketch_to_string(sketch) from cpc_sketch_test;
+
+-- default lgk and type
+select cpc_sketch_get_estimate(cpc_sketch_union(sketch)) from cpc_sketch_test;
+-- lgk = 8
+select cpc_sketch_get_estimate(cpc_sketch_union(sketch, 8)) from cpc_sketch_test;
+
+drop table cpc_sketch_test;
+drop extension datasketches;
diff --git a/test/hll_sketch_test.sql b/test/hll_sketch_test.sql
new file mode 100644
index 0000000..27d0b4f
--- /dev/null
+++ b/test/hll_sketch_test.sql
@@ -0,0 +1,28 @@
+drop extension if exists datasketches cascade;
+create extension datasketches;
+
+drop table if exists hll_sketch_test;
+create table hll_sketch_test(sketch hll_sketch);
+
+-- default lgk and type
+insert into hll_sketch_test
+  select hll_sketch_build(value)
+  from (values (1), (2), (3), (4), (5)) as t(value)
+;
+
+-- lgk = 8 and type = HLL_6
+insert into hll_sketch_test
+  select hll_sketch_build(value, 8, 6)
+  from (values (4), (5), (6), (7), (8)) as t(value)
+;
+
+select hll_sketch_get_estimate(sketch) from hll_sketch_test;
+--select hll_sketch_to_string(sketch) from hll_sketch_test;
+
+-- default lgk and type
+select hll_sketch_get_estimate(hll_sketch_union(sketch)) from hll_sketch_test;
+-- lgk = 8 and type = HLL_6
+select hll_sketch_get_estimate(hll_sketch_union(sketch, 8, 6)) from hll_sketch_test;
+
+drop table hll_sketch_test;
+drop extension datasketches;
diff --git a/test/kll_sketch_test.sql b/test/kll_sketch_test.sql
new file mode 100644
index 0000000..d62edde
--- /dev/null
+++ b/test/kll_sketch_test.sql
@@ -0,0 +1,29 @@
+drop extension if exists datasketches cascade;
+create extension datasketches;
+
+drop table if exists kll_sketch_test;
+create table kll_sketch_test(sketch kll_float_sketch);
+
+-- default k
+insert into kll_sketch_test
+  select kll_float_sketch_build(value)
+  from (values (1), (2), (3), (4), (5)) as t(value)
+;
+
+-- k = 20
+insert into kll_sketch_test
+  select kll_float_sketch_build(value, 20)
+  from (values (6), (7), (8), (9), (10)) as t(value)
+;
+
+-- get min and max values
+select kll_float_sketch_get_quantiles(sketch, array[0, 1]) as min_max from kll_sketch_test;
+select kll_float_sketch_to_string(sketch) from kll_sketch_test;
+
+-- default k, median
+select kll_float_sketch_get_quantile(kll_float_sketch_merge(sketch), 0.5) as median from kll_sketch_test;
+-- k = 20, rank of value 6
+select kll_float_sketch_get_rank(kll_float_sketch_merge(sketch, 20), 6) as rank from kll_sketch_test;
+
+drop table kll_sketch_test;
+drop extension datasketches;
diff --git a/test/theta_sketch_test.sql b/test/theta_sketch_test.sql
new file mode 100644
index 0000000..62a69c2
--- /dev/null
+++ b/test/theta_sketch_test.sql
@@ -0,0 +1,33 @@
+drop extension if exists datasketches cascade;
+create extension datasketches;
+
+drop table if exists theta_sketch_test;
+create table theta_sketch_test(sketch theta_sketch);
+
+-- default lgk
+insert into theta_sketch_test
+  select theta_sketch_build(value)
+  from (values (1), (2), (3), (4), (5)) as t(value)
+;
+
+-- lgk = 16
+insert into theta_sketch_test
+  select theta_sketch_build(value, 16)
+  from (values (4), (5), (6), (7), (8)) as t(value)
+;
+
+select theta_sketch_get_estimate(sketch) from theta_sketch_test;
+--select theta_sketch_to_string(sketch) from theta_sketch_test;
+
+-- default lgk
+select theta_sketch_get_estimate(theta_sketch_union(sketch)) from theta_sketch_test;
+-- lgk = 16
+select theta_sketch_get_estimate(theta_sketch_union(sketch, 16)) from theta_sketch_test;
+
+select theta_sketch_get_estimate(theta_sketch_intersection(sketch)) from theta_sketch_test;
+
+select theta_sketch_get_estimate(theta_sketch_a_not_b(theta_sketch_build(value1), theta_sketch_build(value2)))
+from (values (1, 2), (2, 3), (3, 4)) as t(value1, value2);
+
+drop table theta_sketch_test;
+drop extension datasketches;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org