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 2024/07/27 01:05:44 UTC

(datasketches-cpp) branch minor_cleanup created (now 5a334d4)

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

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


      at 5a334d4  minor cleanup

This branch includes the following new commits:

     new 5a334d4  minor cleanup

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: minor cleanup

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

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

commit 5a334d4acdc28a1d99182ed15db21655cab56422
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Fri Jul 26 18:05:36 2024 -0700

    minor cleanup
---
 kll/test/kll_sketch_custom_type_test.cpp | 11 ++++++-----
 theta/test/bit_packing_test.cpp          | 17 +++++++++--------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/kll/test/kll_sketch_custom_type_test.cpp b/kll/test/kll_sketch_custom_type_test.cpp
index 784197d..f9d6f3c 100644
--- a/kll/test/kll_sketch_custom_type_test.cpp
+++ b/kll/test/kll_sketch_custom_type_test.cpp
@@ -31,11 +31,14 @@ using alloc = test_allocator<test_type>;
 
 TEST_CASE("kll sketch custom type", "[kll_sketch]") {
 
-  // setup section
   test_allocator_total_bytes = 0;
+  test_allocator_net_allocations = 0;
 
   SECTION("compact level zero") {
     kll_test_type_sketch sketch(8, test_type_less(), 0);
+    REQUIRE(test_allocator_total_bytes != 0);
+    REQUIRE(test_allocator_net_allocations != 0);
+
     REQUIRE_THROWS_AS(sketch.get_quantile(0), std::runtime_error);
     REQUIRE_THROWS_AS(sketch.get_min_item(), std::runtime_error);
     REQUIRE_THROWS_AS(sketch.get_max_item(), std::runtime_error);
@@ -146,10 +149,8 @@ TEST_CASE("kll sketch custom type", "[kll_sketch]") {
     REQUIRE(sketch2.get_n() == 11);
   }
 
-  // cleanup
-  if (test_allocator_total_bytes != 0) {
-    REQUIRE(test_allocator_total_bytes == 0);
-  }
+  REQUIRE(test_allocator_total_bytes == 0);
+  REQUIRE(test_allocator_net_allocations == 0);
 }
 
 } /* namespace datasketches */
diff --git a/theta/test/bit_packing_test.cpp b/theta/test/bit_packing_test.cpp
index 0273280..2e25a4a 100644
--- a/theta/test/bit_packing_test.cpp
+++ b/theta/test/bit_packing_test.cpp
@@ -30,29 +30,30 @@ static const uint64_t IGOLDEN64 = 0x9e3779b97f4a7c13ULL;
 
 TEST_CASE("pack unpack bits") {
   for (uint8_t bits = 1; bits <= 63; ++bits) {
+    int n = 8;
     const uint64_t mask = (1ULL << bits) - 1;
-    std::vector<uint64_t> input(8, 0);
+    std::vector<uint64_t> input(n, 0);
     const uint64_t igolden64 = IGOLDEN64;
     uint64_t value = 0xaa55aa55aa55aa55ULL; // arbitrary starting value
-    for (int i = 0; i < 8; ++i) {
+    for (int i = 0; i < n; ++i) {
       input[i] = value & mask;
       value += igolden64;
     }
-    std::vector<uint8_t> bytes(8 * sizeof(uint64_t), 0);
+    std::vector<uint8_t> bytes(n * sizeof(uint64_t), 0);
     uint8_t offset = 0;
     uint8_t* ptr = bytes.data();
-    for (int i = 0; i < 8; ++i) {
+    for (int i = 0; i < n; ++i) {
       offset = pack_bits(input[i], bits, ptr, offset);
     }
 
-    std::vector<uint64_t> output(8, 0);
+    std::vector<uint64_t> output(n, 0);
     offset = 0;
     const uint8_t* cptr = bytes.data();
-    for (int i = 0; i < 8; ++i) {
+    for (int i = 0; i < n; ++i) {
       offset = unpack_bits(output[i], bits, cptr, offset);
     }
-    for (int i = 0; i < 8; ++i) {
-      REQUIRE((input[i] & mask) == output[i]);
+    for (int i = 0; i < n; ++i) {
+      REQUIRE(input[i] == output[i]);
     }
   }
 }


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