You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2022/03/26 02:13:40 UTC

[datasketches-cpp] branch quantiles updated: updates to reduce warnings

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

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


The following commit(s) were added to refs/heads/quantiles by this push:
     new 4813ab6  updates to reduce warnings
4813ab6 is described below

commit 4813ab62a726cdad2df44cdcb32445e30795c77a
Author: Jon Malkin <jm...@users.noreply.github.com>
AuthorDate: Fri Mar 25 19:13:31 2022 -0700

    updates to reduce warnings
---
 quantiles/include/quantiles_sketch.hpp      |  6 +++---
 quantiles/include/quantiles_sketch_impl.hpp | 18 +++++++++---------
 quantiles/test/quantiles_sketch_test.cpp    |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/quantiles/include/quantiles_sketch.hpp b/quantiles/include/quantiles_sketch.hpp
index 5ea7a42..ade5fa4 100644
--- a/quantiles/include/quantiles_sketch.hpp
+++ b/quantiles/include/quantiles_sketch.hpp
@@ -519,7 +519,7 @@ private:
    * @param starting_bit the zero-based starting bit position. Only the low 6 bits are used.
    * @return the zero-based bit position of the lowest zero bit starting at <i>startingBit</i>.
    */
-  static int lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit);
+  static uint8_t lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit);
 
   // implementations for floating point types
   template<typename TT = T, typename std::enable_if<std::is_floating_point<TT>::value, int>::type = 0>
@@ -583,10 +583,10 @@ private:
   std::vector<Level, AllocLevel> levels_;
   int level_;
   uint32_t index_;
-  uint16_t k_;
-  uint16_t bb_count_;
+  uint32_t bb_count_;
   uint64_t bit_pattern_;
   uint64_t weight_;
+  uint16_t k_;
   const_iterator(const Level& base_buffer, const std::vector<Level, AllocLevel>& levels, uint16_t k, uint64_t n, bool is_end);
 };
 
diff --git a/quantiles/include/quantiles_sketch_impl.hpp b/quantiles/include/quantiles_sketch_impl.hpp
index fae759f..34040a1 100644
--- a/quantiles/include/quantiles_sketch_impl.hpp
+++ b/quantiles/include/quantiles_sketch_impl.hpp
@@ -193,12 +193,12 @@ void quantiles_sketch<T, C, A>::serialize(std::ostream& os, const SerDe& serde)
     serde.serialize(os, max_value_, 1);
 
     // base buffer items
-    serde.serialize(os, base_buffer_.data(), base_buffer_.size());
+    serde.serialize(os, base_buffer_.data(), static_cast<unsigned>(base_buffer_.size()));
 
     // levels, only when data is present
     for (Level lvl : levels_) {
       if (lvl.size() > 0)
-        serde.serialize(os, lvl.data(), lvl.size());
+        serde.serialize(os, lvl.data(), static_cast<unsigned>(lvl.size()));
     }
   }
 }
@@ -238,12 +238,12 @@ auto quantiles_sketch<T, C, A>::serialize(unsigned header_size_bytes, const SerD
  
     // base buffer items
     if (base_buffer_.size() > 0)
-      ptr += serde.serialize(ptr, end_ptr - ptr, base_buffer_.data(), base_buffer_.size());
+      ptr += serde.serialize(ptr, end_ptr - ptr, base_buffer_.data(), static_cast<unsigned>(base_buffer_.size()));
     
     // levels, only when data is present
     for (Level lvl : levels_) {
       if (lvl.size() > 0)
-        ptr += serde.serialize(ptr, end_ptr - ptr, lvl.data(), lvl.size());
+        ptr += serde.serialize(ptr, end_ptr - ptr, lvl.data(), static_cast<unsigned>(lvl.size()));
     }
   }
 
@@ -602,7 +602,7 @@ auto quantiles_sketch<T, C, A>::get_quantile_calculator() const -> QuantileCalcu
     calculator_deleter(ac)
   );
 
-  uint64_t lg_weight = 0;
+  uint8_t lg_weight = 0;
   quantile_calculator_ptr->add(base_buffer_.data(), base_buffer_.data() + base_buffer_.size(), lg_weight);
   for (auto& level : levels_) {
     ++lg_weight;
@@ -928,7 +928,7 @@ void quantiles_sketch<T, C, A>::merge_two_size_k_buffers(Level& src_1, Level& sr
 }
 
 template<typename T, typename C, typename A>
-int quantiles_sketch<T, C, A>::lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit) {
+uint8_t quantiles_sketch<T, C, A>::lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit) {
   uint8_t pos = starting_bit & 0X3F;
   uint64_t my_bits = bits >> pos;
 
@@ -987,10 +987,10 @@ base_buffer_(base_buffer),
 levels_(levels),
 level_(-1),
 index_(0),
-k_(k),
 bb_count_(compute_base_buffer_items(k, n)),
 bit_pattern_(compute_bit_pattern(k, n)),
-weight_(1)
+weight_(1),
+k_(k)
 {
   if (is_end) {
     // if exact mode: index_ = n is end
@@ -998,7 +998,7 @@ weight_(1)
     if (bit_pattern_ == 0) // only a valid check for exact mode in constructor
       index_ = static_cast<uint32_t>(n);
     else
-      level_ = levels_.size();
+      level_ = static_cast<int>(levels_.size());
   } else { // find first non-empty item
     if (bb_count_ == 0 && bit_pattern_ > 0) {
       level_ = 0;
diff --git a/quantiles/test/quantiles_sketch_test.cpp b/quantiles/test/quantiles_sketch_test.cpp
index c6243a1..daa9be4 100644
--- a/quantiles/test/quantiles_sketch_test.cpp
+++ b/quantiles/test/quantiles_sketch_test.cpp
@@ -78,7 +78,7 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {
 
   SECTION("get bad quantile") {
     quantiles_float_sketch sketch(200, 0);
-    sketch.update(0); // has to be non-empty to reach the check
+    sketch.update(0.0); // has to be non-empty to reach the check
     REQUIRE_THROWS_AS(sketch.get_quantile(-1), std::invalid_argument);
   }
 

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