proost commented on code in PR #565:
URL: https://github.com/apache/datasketches-cpp/pull/565#discussion_r4490138937
##########
hll/include/CouponHashSet-internal.hpp:
##########
@@ -83,12 +83,20 @@ CouponHashSet<A>* CouponHashSet<A>::newSet(const void*
bytes, size_t len, const
if (lgK <= 7) {
throw std::invalid_argument("Attempt to deserialize invalid CouponHashSet
with lgConfigK <= 7. Found: "
+ std::to_string(lgK));
- }
+ }
+ HllUtil<A>::checkLgK(lgK);
uint8_t lgArrInts = data[hll_constants::LG_ARR_BYTE];
const bool compactFlag = ((data[hll_constants::FLAGS_BYTE] &
hll_constants::COMPACT_FLAG_MASK) ? true : false);
uint32_t couponCount;
std::memcpy(&couponCount, data + hll_constants::HASH_SET_COUNT_INT,
sizeof(couponCount));
+ const uint32_t maxCouponCount = hll_constants::RESIZE_NUMER * (uint32_t(1)
<< (lgK - 3))
+ / hll_constants::RESIZE_DENOM;
+ if (compactFlag && couponCount > maxCouponCount) {
Review Comment:
why this guard only for compact?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]