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

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


The following commit(s) were added to refs/heads/cleanup_warnings by this push:
     new c7a203e  types and casts
     new 10925a8  Merge branch 'cleanup_warnings' of 
https://github.com/apache/datasketches-cpp into cleanup_warnings
c7a203e is described below

commit c7a203e5ec1410dfbcf88ea159ab08ef82d666d1
Author: Alexander Saydakov <[email protected]>
AuthorDate: Tue Apr 6 19:01:49 2021 -0700

    types and casts
---
 sampling/include/var_opt_sketch_impl.hpp |  2 +-
 sampling/include/var_opt_union_impl.hpp  |  4 ++--
 sampling/test/var_opt_sketch_test.cpp    | 10 +++++-----
 sampling/test/var_opt_union_test.cpp     | 24 ++++++++++++------------
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/sampling/include/var_opt_sketch_impl.hpp 
b/sampling/include/var_opt_sketch_impl.hpp
index 33be587..dbfe5a4 100644
--- a/sampling/include/var_opt_sketch_impl.hpp
+++ b/sampling/include/var_opt_sketch_impl.hpp
@@ -1411,7 +1411,7 @@ subset_summary var_opt_sketch<T, S, 
A>::estimate_subset_sum(P predicate) const {
   if (effective_sampling_rate < 0.0 || effective_sampling_rate > 1.0)
     throw std::logic_error("invalid sampling rate outside [0.0, 1.0]");
 
-  size_t r_true_count = 0;
+  uint32_t r_true_count = 0;
   ++idx; // skip the gap
   for (; idx < (k_ + 1); ++idx) {
     if (predicate(data_[idx])) {
diff --git a/sampling/include/var_opt_union_impl.hpp 
b/sampling/include/var_opt_union_impl.hpp
index 3752016..fe1ee49 100644
--- a/sampling/include/var_opt_union_impl.hpp
+++ b/sampling/include/var_opt_union_impl.hpp
@@ -30,8 +30,8 @@ namespace datasketches {
 template<typename T, typename S, typename A>
 var_opt_union<T,S,A>::var_opt_union(uint32_t max_k, const A& allocator) :
   n_(0),
-  outer_tau_numer_(0),
-  outer_tau_denom_(0.0),
+  outer_tau_numer_(0.0),
+  outer_tau_denom_(0),
   max_k_(max_k),
   gadget_(max_k, var_opt_sketch<T,S,A>::DEFAULT_RESIZE_FACTOR, true, allocator)
 {}
diff --git a/sampling/test/var_opt_sketch_test.cpp 
b/sampling/test/var_opt_sketch_test.cpp
index 44560c9..af1cf8c 100644
--- a/sampling/test/var_opt_sketch_test.cpp
+++ b/sampling/test/var_opt_sketch_test.cpp
@@ -41,7 +41,7 @@ static constexpr double EPS = 1e-13;
 static var_opt_sketch<int> create_unweighted_sketch(uint32_t k, uint64_t n) {
   var_opt_sketch<int> sk(k);
   for (uint64_t i = 0; i < n; ++i) {
-    sk.update(i, 1.0);
+    sk.update(static_cast<int>(i), 1.0);
   }
   return sk;
 }
@@ -71,7 +71,7 @@ static void check_if_equal(var_opt_sketch<T,S,A>& sk1, 
var_opt_sketch<T,S,A>& sk
 
 TEST_CASE("varopt sketch: invalid k", "[var_opt_sketch]") {
   REQUIRE_THROWS_AS(var_opt_sketch<int>(0), std::invalid_argument);
-  REQUIRE_THROWS_AS(var_opt_sketch<int>(1 << 31), std::invalid_argument); // 
aka k < 0
+  REQUIRE_THROWS_AS(var_opt_sketch<int>(1U << 31), std::invalid_argument); // 
aka k < 0
 }
 
 TEST_CASE("varopt sketch: bad serialization version", "[var_opt_sketch]") {
@@ -216,7 +216,7 @@ TEST_CASE("varopt sketch: cumulative weight", 
"[var_opt_sketch]") {
     // which covers about 10 orders of magnitude
     double w = std::exp(5 * N(rand));
     input_sum += w;
-    sk.update(i, w);
+    sk.update(static_cast<int>(i), w);
   }
 
   double output_sum = 0.0;
@@ -350,7 +350,7 @@ TEST_CASE("varopt sketch: pseudo-heavy update", 
"[var_opt_sketch]") {
   // Last one should call update_pseudo_heavy_r_eq_1(), since we'll have
   // added k-1 heavy items, leaving only 1 item left in R
   for (uint32_t i = 1; i <= k; ++i) {
-    sk.update(-i, k + (i * wt_scale));
+    sk.update(-1 * static_cast<int>(i), k + (i * wt_scale));
   }
 
   auto it = sk.begin();
@@ -442,7 +442,7 @@ TEST_CASE("varopt sketch: estimate subset sum", 
"[var_opt_sketch]") {
   // finally, a non-degenerate predicate
   // insert negative items with identical weights, filter for negative weights 
only
   for (uint32_t i = 1; i <= (k + 1); ++i) {
-    sk.update(static_cast<int32_t>(-i), 1.0 * i);
+    sk.update(-1 * static_cast<int32_t>(i), static_cast<double>(i));
     total_weight += 1.0 * i;
   }
 
diff --git a/sampling/test/var_opt_union_test.cpp 
b/sampling/test/var_opt_union_test.cpp
index e3343d9..f9b653b 100644
--- a/sampling/test/var_opt_union_test.cpp
+++ b/sampling/test/var_opt_union_test.cpp
@@ -40,7 +40,7 @@ static constexpr double EPS = 1e-13;
 
 static var_opt_sketch<int> create_unweighted_sketch(uint32_t k, uint64_t n) {
   var_opt_sketch<int> sk(k);
-  for (uint64_t i = 0; i < n; ++i) {
+  for (int i = 0; i < n; ++i) {
     sk.update(i, 1.0);
   }
   return sk;
@@ -147,7 +147,7 @@ TEST_CASE("varopt union: bad serialization version", 
"[var_opt_union]") {
 
 TEST_CASE("varopt union: invalid k", "[var_opt_union]") {
   REQUIRE_THROWS_AS(var_opt_union<int>(0), std::invalid_argument);
-  REQUIRE_THROWS_AS(var_opt_union<int>(1<<31), std::invalid_argument);
+  REQUIRE_THROWS_AS(var_opt_union<int>(1U << 31), std::invalid_argument);
 }
 
 TEST_CASE("varopt union: bad family", "[var_opt_union]") {
@@ -179,13 +179,13 @@ TEST_CASE("varopt union: empty union", "[var_opt_union]") 
{
 }
 
 TEST_CASE("varopt union: two exact sketches", "[var_opt_union]") {
-  uint64_t n = 4; // 2n < k
+  int n = 4; // 2n < k
   uint32_t k = 10;
   var_opt_sketch<int> sk1(k), sk2(k);
 
-  for (uint64_t i = 1; i <= n; ++i) {
-    sk1.update(i, i);
-    sk2.update(static_cast<int64_t>(-i), i);
+  for (int i = 1; i <= n; ++i) {
+    sk1.update(i, static_cast<double>(i));
+    sk2.update(-i, static_cast<double>(i));
   }
 
   var_opt_union<int> u(k);
@@ -204,13 +204,13 @@ TEST_CASE("varopt union: heavy sampling sketch", 
"[var_opt_union]") {
   uint32_t k2 = 5;
   var_opt_sketch<int64_t> sk1(k1), sk2(k2);
   for (uint64_t i = 1; i <= n1; ++i) {
-    sk1.update(i, i);
+    sk1.update(i, static_cast<double>(i));
   }
 
   for (uint64_t i = 1; i < n2; ++i) { // we'll add a very heavy one later
-    sk2.update(static_cast<int64_t>(-i), i + 1000.0);
+    sk2.update(-1 * static_cast<int64_t>(i), i + 1000.0);
   }
-  sk2.update(-n2, 1000000.0);
+  sk2.update(-1 * static_cast<int64_t>(n2), 1000000.0);
 
   var_opt_union<int64_t> u(k1);
   u.update(sk1);
@@ -258,15 +258,15 @@ TEST_CASE("varopt union: small sampling sketch", 
"[var_opt_union]") {
   uint64_t n2 = 64;
 
   var_opt_sketch<float> sk(k_small);
-  for (uint64_t i = 0; i < n1; ++i) { sk.update(i); }
-  sk.update(-1, n1 * n1); // add a heavy item
+  for (uint64_t i = 0; i < n1; ++i) { sk.update(static_cast<float>(i)); }
+  sk.update(-1.0f, static_cast<double>(n1 * n1)); // add a heavy item
 
   var_opt_union<float> u(k_max);
   u.update(sk);
 
   // another one, but different n to get a different per-item weight
   var_opt_sketch<float> sk2(k_small);
-  for (uint64_t i = 0; i < n2; ++i) { sk2.update(i); }
+  for (uint64_t i = 0; i < n2; ++i) { sk2.update(static_cast<float>(i)); }
   u.update(sk2);
 
   // should trigger migrate_marked_items_by_decreasing_k()

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to