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/12/10 22:17:34 UTC
[datasketches-cpp] branch test_deserialize_exact_from_java created (now 619a146)
This is an automated email from the ASF dual-hosted git repository.
alsay pushed a change to branch test_deserialize_exact_from_java
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git.
at 619a146 added missing test
This branch includes the following new commits:
new 619a146 added missing test
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org
[datasketches-cpp] 01/01: added missing test
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alsay pushed a commit to branch test_deserialize_exact_from_java
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
commit 619a146c381c49acb39e9bf02f451bb704a6f7c3
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Dec 10 14:17:22 2021 -0800
added missing test
---
theta/test/theta_compact_exact_from_java.sk | Bin 0 -> 816 bytes
theta/test/theta_sketch_test.cpp | 32 ++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/theta/test/theta_compact_exact_from_java.sk b/theta/test/theta_compact_exact_from_java.sk
new file mode 100644
index 0000000..30e4f77
Binary files /dev/null and b/theta/test/theta_compact_exact_from_java.sk differ
diff --git a/theta/test/theta_sketch_test.cpp b/theta/test/theta_sketch_test.cpp
index b5bb680..091a9c7 100644
--- a/theta/test/theta_sketch_test.cpp
+++ b/theta/test/theta_sketch_test.cpp
@@ -222,6 +222,38 @@ TEST_CASE("theta sketch: deserialize single item from java", "[theta_sketch]") {
REQUIRE(sketch.get_upper_bound(1) == 1.0);
}
+TEST_CASE("theta sketch: deserialize compact exact from java", "[theta_sketch]") {
+ std::ifstream is;
+ is.exceptions(std::ios::failbit | std::ios::badbit);
+ is.open(inputPath + "theta_compact_exact_from_java.sk", std::ios::binary);
+ auto sketch = compact_theta_sketch::deserialize(is);
+ REQUIRE_FALSE(sketch.is_empty());
+ REQUIRE_FALSE(sketch.is_estimation_mode());
+ REQUIRE(sketch.is_ordered());
+ REQUIRE(sketch.get_num_retained() == 100);
+
+ // the same construction process in Java must have produced exactly the same sketch
+ auto update_sketch = update_theta_sketch::builder().build();
+ const int n = 100;
+ for (int i = 0; i < n; i++) update_sketch.update(i);
+ REQUIRE(sketch.get_num_retained() == update_sketch.get_num_retained());
+ REQUIRE(sketch.get_theta() == Approx(update_sketch.get_theta()).margin(1e-10));
+ REQUIRE(sketch.get_estimate() == Approx(update_sketch.get_estimate()).margin(1e-10));
+ REQUIRE(sketch.get_lower_bound(1) == Approx(update_sketch.get_lower_bound(1)).margin(1e-10));
+ REQUIRE(sketch.get_upper_bound(1) == Approx(update_sketch.get_upper_bound(1)).margin(1e-10));
+ REQUIRE(sketch.get_lower_bound(2) == Approx(update_sketch.get_lower_bound(2)).margin(1e-10));
+ REQUIRE(sketch.get_upper_bound(2) == Approx(update_sketch.get_upper_bound(2)).margin(1e-10));
+ REQUIRE(sketch.get_lower_bound(3) == Approx(update_sketch.get_lower_bound(3)).margin(1e-10));
+ REQUIRE(sketch.get_upper_bound(3) == Approx(update_sketch.get_upper_bound(3)).margin(1e-10));
+ compact_theta_sketch compact_sketch = update_sketch.compact();
+ // the sketches are ordered, so the iteration sequence must match exactly
+ auto iter = sketch.begin();
+ for (const auto& key: compact_sketch) {
+ REQUIRE(*iter == key);
+ ++iter;
+ }
+}
+
TEST_CASE("theta sketch: deserialize compact estimation from java", "[theta_sketch]") {
std::ifstream is;
is.exceptions(std::ios::failbit | std::ios::badbit);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org