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 2019/07/30 22:31:25 UTC

[incubator-datasketches-cpp] branch hll_cleanup updated: type mismatch and const

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

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


The following commit(s) were added to refs/heads/hll_cleanup by this push:
     new 6e3c956  type mismatch and const
6e3c956 is described below

commit 6e3c95640c37e04636d1d568cd5f0d113cc728d7
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Tue Jul 30 15:31:18 2019 -0700

    type mismatch and const
---
 hll/include/CouponHashSet-internal.hpp |  6 +++---
 hll/include/CouponList-internal.hpp    | 11 +++++------
 hll/include/HllArray-internal.hpp      |  2 +-
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/hll/include/CouponHashSet-internal.hpp b/hll/include/CouponHashSet-internal.hpp
index 49dcf8a..1b2665c 100644
--- a/hll/include/CouponHashSet-internal.hpp
+++ b/hll/include/CouponHashSet-internal.hpp
@@ -39,7 +39,7 @@ CouponHashSet<A>::CouponHashSet(const int lgConfigK, const TgtHllType tgtHllType
   if (lgConfigK <= 7) {
     throw std::invalid_argument("CouponHashSet must be initialized with lgConfigK > 7. Found: "
                                 + std::to_string(lgConfigK));
-  }   
+  }
 }
 
 template<typename A>
@@ -102,8 +102,8 @@ CouponHashSet<A>* CouponHashSet<A>::newSet(const void* bytes, size_t len) {
   // Don't set couponCount in sketch here;
   // we'll set later if updatable, and increment with updates if compact
   //int couponsInArray = (compactFlag ? couponCount : (1 << sketch->getLgCouponArrInts()));
-  int couponsInArray = (compactFlag ? couponCount : (1 << lgArrInts));
-  int expectedLength = HllUtil<A>::HASH_SET_INT_ARR_START + (couponsInArray * sizeof(int));
+  const int couponsInArray = (compactFlag ? couponCount : (1 << lgArrInts));
+  const size_t expectedLength = HllUtil<A>::HASH_SET_INT_ARR_START + (couponsInArray * sizeof(int));
   if (len < expectedLength) {
     throw std::invalid_argument("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
                                 + ", found: " + std::to_string(len));
diff --git a/hll/include/CouponList-internal.hpp b/hll/include/CouponList-internal.hpp
index a2111ba..359f6c2 100644
--- a/hll/include/CouponList-internal.hpp
+++ b/hll/include/CouponList-internal.hpp
@@ -125,14 +125,13 @@ CouponList<A>* CouponList<A>::newList(const void* bytes, size_t len) {
   TgtHllType tgtHllType = HllSketchImpl<A>::extractTgtHllType(data[HllUtil<A>::MODE_BYTE]);
 
   const int lgK = (int) data[HllUtil<A>::LG_K_BYTE];
-  //const int lgArrInts = (int) data[HllUtil<A>::LG_ARR_BYTE];
-  bool compact = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
-  bool oooFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
-  bool emptyFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::EMPTY_FLAG_MASK) ? true : false);
+  const bool compact = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::COMPACT_FLAG_MASK) ? true : false);
+  const bool oooFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::OUT_OF_ORDER_FLAG_MASK) ? true : false);
+  const bool emptyFlag = ((data[HllUtil<A>::FLAGS_BYTE] & HllUtil<A>::EMPTY_FLAG_MASK) ? true : false);
 
   const int couponCount = (int) data[HllUtil<A>::LIST_COUNT_BYTE];
-  int couponsInArray = (compact ? couponCount : (1 << HllUtil<A>::computeLgArrInts(LIST, couponCount, lgK)));
-  int expectedLength = HllUtil<A>::LIST_INT_ARR_START + (couponsInArray * sizeof(int));
+  const int couponsInArray = (compact ? couponCount : (1 << HllUtil<A>::computeLgArrInts(LIST, couponCount, lgK)));
+  const size_t expectedLength = HllUtil<A>::LIST_INT_ARR_START + (couponsInArray * sizeof(int));
   if (len < expectedLength) {
     throw std::invalid_argument("Byte array too short for sketch. Expected " + std::to_string(expectedLength)
                                 + ", found: " + std::to_string(len));
diff --git a/hll/include/HllArray-internal.hpp b/hll/include/HllArray-internal.hpp
index 32dcec9..a8fb844 100644
--- a/hll/include/HllArray-internal.hpp
+++ b/hll/include/HllArray-internal.hpp
@@ -128,7 +128,7 @@ HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len) {
   const int curMin = (int) data[HllUtil<A>::HLL_CUR_MIN_BYTE];
 
   int arrayBytes = hllArrBytes(tgtHllType, lgK);
-  if (len < HllUtil<A>::HLL_BYTE_ARR_START + arrayBytes) {
+  if (len < static_cast<size_t>(HllUtil<A>::HLL_BYTE_ARR_START + arrayBytes)) {
     throw std::invalid_argument("Input array too small to hold sketch image");
   }
 


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