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 2022/03/14 22:06:31 UTC

[datasketches-cpp] branch hll-deserialize-test created (now bb9f995)

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

alsay pushed a change to branch hll-deserialize-test
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git.


      at bb9f995  serialize-deserialize-serialize tests

This branch includes the following new commits:

     new bb9f995  serialize-deserialize-serialize tests

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: serialize-deserialize-serialize tests

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch hll-deserialize-test
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git

commit bb9f995a72b238d4e03a19105bc3129f5ca10745
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Mon Mar 14 15:06:03 2022 -0700

    serialize-deserialize-serialize tests
---
 hll/test/HllSketchTest.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/hll/test/HllSketchTest.cpp b/hll/test/HllSketchTest.cpp
index 2550dfa..759048b 100644
--- a/hll/test/HllSketchTest.cpp
+++ b/hll/test/HllSketchTest.cpp
@@ -384,4 +384,61 @@ TEST_CASE("hll sketch: deserialize HLL mode buffer overrun", "[hll_sketch]") {
   REQUIRE(test_allocator_total_bytes == 0);
 }
 
+TEST_CASE("hll sketch: bytes serialize-deserialize-serialize list mode") {
+  test_allocator_total_bytes = 0;
+  {
+    hll_sketch_test_alloc s1(10, target_hll_type::HLL_4, false, 0);
+    s1.update(1);
+    s1.update(2);
+    s1.update(3);
+    std::cout << s1.to_string();
+    auto bytes1 = s1.serialize_compact();
+    auto s2 = hll_sketch_test_alloc::deserialize(bytes1.data(), bytes1.size(), 0);
+    auto bytes2 = s2.serialize_compact();
+    REQUIRE(bytes1 == bytes2);
+  }
+  REQUIRE(test_allocator_total_bytes == 0);
+}
+
+TEST_CASE("hll sketch: updatable bytes serialize-deserialize-serialize set mode") {
+  test_allocator_total_bytes = 0;
+  {
+    hll_sketch_test_alloc s1(10, target_hll_type::HLL_4, false, 0);
+    for (int i = 0; i < 10; ++i) s1.update(i);
+    std::cout << s1.to_string();
+    auto bytes1 = s1.serialize_updatable();
+    auto s2 = hll_sketch_test_alloc::deserialize(bytes1.data(), bytes1.size(), 0);
+
+    auto bytes2 = s2.serialize_updatable();
+    REQUIRE(bytes1 == bytes2);
+  }
+  REQUIRE(test_allocator_total_bytes == 0);
+}
+
+TEST_CASE("hll sketch: compact bytes serialize-deserialize-serialize set mode") {
+  test_allocator_total_bytes = 0;
+  {
+    hll_sketch_test_alloc s1(10, target_hll_type::HLL_4, false, 0);
+    for (int i = 0; i < 10; ++i) s1.update(i);
+    std::cout << s1.to_string();
+    auto bytes1 = s1.serialize_compact();
+    auto s2 = hll_sketch_test_alloc::deserialize(bytes1.data(), bytes1.size(), 0);
+
+    // cannot just compare bytes here
+    // hash set does not preserve the order after reconstruction in compact mode
+    // add more to push them to HLL mode
+    for (int i = 10; i < 100; ++i) {
+      s1.update(i);
+      s2.update(i);
+    }
+    std::cout << s1.to_string();
+    std::cout << s2.to_string();
+
+    auto bytes2 = s1.serialize_compact();
+    auto bytes3 = s2.serialize_compact();
+    REQUIRE(bytes2 == bytes3);
+  }
+  REQUIRE(test_allocator_total_bytes == 0);
+}
+
 } /* namespace datasketches */

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