You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by GitBox <gi...@apache.org> on 2022/03/24 07:54:39 UTC
[GitHub] [datasketches-cpp] jmalkin commented on a change in pull request #267: serialize-deserialize-serialize tests
jmalkin commented on a change in pull request #267:
URL: https://github.com/apache/datasketches-cpp/pull/267#discussion_r834012263
##########
File path: 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
Review comment:
This is rather annoying with such a small table. Oh well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org