diff --git a/hll/include/CouponHashSet-internal.hpp b/hll/include/CouponHashSet-internal.hpp index 7474cf2c..2ec4d6a8 100644 --- a/hll/include/CouponHashSet-internal.hpp +++ b/hll/include/CouponHashSet-internal.hpp @@ -176,8 +176,7 @@ CouponHashSet* CouponHashSet::newSet(std::istream& is, const A& allocator) read(is, sketch->coupons_.data(), sketch->coupons_.size() * sizeof(uint32_t)); } - if (!is.good()) - throw std::runtime_error("error reading from std::istream"); + if (!is.good()) { throw std::runtime_error("error reading from std::istream"); } return ptr.release(); } diff --git a/hll/include/CouponList-internal.hpp b/hll/include/CouponList-internal.hpp index a240a000..c92820e2 100644 --- a/hll/include/CouponList-internal.hpp +++ b/hll/include/CouponList-internal.hpp @@ -162,8 +162,7 @@ CouponList* CouponList::newList(std::istream& is, const A& allocator) { read(is, sketch->coupons_.data(), numToRead * sizeof(uint32_t)); } - if (!is.good()) - throw std::runtime_error("error reading from std::istream"); + if (!is.good()) { throw std::runtime_error("error reading from std::istream"); } return ptr.release(); } diff --git a/hll/include/CubicInterpolation-internal.hpp b/hll/include/CubicInterpolation-internal.hpp index 9677b99d..fb74c402 100644 --- a/hll/include/CubicInterpolation-internal.hpp +++ b/hll/include/CubicInterpolation-internal.hpp @@ -165,10 +165,10 @@ static int recursiveFindStraddle(const double xArr[], const int l, const int r, throw std::logic_error("target value invariant violated in search"); } - if (l+1 == r) return (l); + if (l+1 == r) { return (l); } m = l + ((r-l)/2); - if (xArr[m] <= x) return (recursiveFindStraddle(xArr, m, r, x)); - else return (recursiveFindStraddle(xArr, l, m, x)); + if (xArr[m] <= x) { return (recursiveFindStraddle(xArr, m, r, x)); } + else { return (recursiveFindStraddle(xArr, l, m, x)); } } diff --git a/hll/include/Hll4Array-internal.hpp b/hll/include/Hll4Array-internal.hpp index 9d22006b..082f168f 100644 --- a/hll/include/Hll4Array-internal.hpp +++ b/hll/include/Hll4Array-internal.hpp @@ -131,7 +131,7 @@ uint8_t Hll4Array::getSlot(uint32_t slotNo) const { template uint8_t Hll4Array::adjustRawValue(uint32_t slot, uint8_t value) const { - if (value != hll_constants::AUX_TOKEN) return value + this->curMin_; + if (value != hll_constants::AUX_TOKEN) { return value + this->curMin_; } return auxHashMap_->mustFindValueFor(slot); } diff --git a/hll/include/HllArray-internal.hpp b/hll/include/HllArray-internal.hpp index 8986f068..62ea7f78 100644 --- a/hll/include/HllArray-internal.hpp +++ b/hll/include/HllArray-internal.hpp @@ -142,15 +142,16 @@ HllArray* HllArray::newHll(const void* bytes, size_t len, const A& allocat HllArray* sketch = HllSketchImplFactory::newHll(lgK, tgtHllType, startFullSizeFlag, allocator); sketch->putCurMin(curMin); sketch->putOutOfOrderFlag(oooFlag); - if (!oooFlag) sketch->putHipAccum(hip); + if (!oooFlag) { sketch->putHipAccum(hip); } sketch->putKxQ0(kxq0); sketch->putKxQ1(kxq1); sketch->putNumAtCurMin(numAtCurMin); std::memcpy(sketch->hllByteArr_.data(), data + hll_constants::HLL_BYTE_ARR_START, arrayBytes); - if (auxHashMap != nullptr) + if (auxHashMap != nullptr) { ((Hll4Array*)sketch)->putAuxHashMap(auxHashMap); + } aux_ptr.release(); return sketch; @@ -193,7 +194,7 @@ HllArray* HllArray::newHll(std::istream& is, const A& allocator) { const auto hip = read(is); const auto kxq0 = read(is); const auto kxq1 = read(is); - if (!oooFlag) sketch->putHipAccum(hip); + if (!oooFlag) { sketch->putHipAccum(hip); } sketch->putKxQ0(kxq0); sketch->putKxQ1(kxq1); @@ -209,8 +210,7 @@ HllArray* HllArray::newHll(std::istream& is, const A& allocator) { ((Hll4Array*)sketch)->putAuxHashMap(auxHashMap); } - if (!is.good()) - throw std::runtime_error("error reading from std::istream"); + if (!is.good()) { throw std::runtime_error("error reading from std::istream"); } return sketch_ptr.release(); } @@ -545,7 +545,7 @@ template void HllArray::hipAndKxQIncrementalUpdate(uint8_t oldValue, uint8_t newValue) { const uint32_t configK = 1 << this->getLgConfigK(); // update hip BEFORE updating kxq - if (!oooFlag_) hipAccum_ += configK / (kxq0_ + kxq1_); + if (!oooFlag_) { hipAccum_ += configK / (kxq0_ + kxq1_); } // update kxq0 and kxq1; subtract first, then add if (oldValue < 32) { kxq0_ -= INVERSE_POWERS_OF_2[oldValue]; } else { kxq1_ -= INVERSE_POWERS_OF_2[oldValue]; } @@ -648,7 +648,7 @@ array_(array), array_size_(array_size), index_(index), hll_type_(hll_type), exce { while (index_ < array_size_) { value_ = get_value(array_, index_, hll_type_, exceptions_, offset_); - if (all_ || value_ != hll_constants::EMPTY) break; + if (all_ || value_ != hll_constants::EMPTY) { break; } ++index_; } } @@ -657,7 +657,7 @@ template typename HllArray::const_iterator& HllArray::const_iterator::operator++() { while (++index_ < array_size_) { value_ = get_value(array_, index_, hll_type_, exceptions_, offset_); - if (all_ || value_ != hll_constants::EMPTY) break; + if (all_ || value_ != hll_constants::EMPTY) { break; } } return *this; } diff --git a/hll/include/HllUnion-internal.hpp b/hll/include/HllUnion-internal.hpp index 3a5a926c..27adab74 100644 --- a/hll/include/HllUnion-internal.hpp +++ b/hll/include/HllUnion-internal.hpp @@ -44,13 +44,13 @@ hll_sketch_alloc hll_union_alloc::get_result(target_hll_type target_type) template void hll_union_alloc::update(const hll_sketch_alloc& sketch) { - if (sketch.is_empty()) return; + if (sketch.is_empty()) { return; } union_impl(sketch, lg_max_k_); } template void hll_union_alloc::update(hll_sketch_alloc&& sketch) { - if (sketch.is_empty()) return; + if (sketch.is_empty()) { return; } if (gadget_.is_empty() && sketch.get_target_type() == HLL_8 && sketch.get_lg_config_k() <= lg_max_k_) { if (sketch.get_current_mode() == HLL || sketch.get_lg_config_k() == lg_max_k_) { gadget_ = std::move(sketch); @@ -131,29 +131,33 @@ void hll_union_alloc::coupon_update(uint32_t coupon) { template double hll_union_alloc::get_estimate() const { - if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) + if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) { static_cast*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min(); + } return gadget_.get_estimate(); } template double hll_union_alloc::get_composite_estimate() const { - if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) + if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) { static_cast*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min(); + } return gadget_.get_composite_estimate(); } template double hll_union_alloc::get_lower_bound(uint8_t num_std_dev) const { - if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) + if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) { static_cast*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min(); + } return gadget_.get_lower_bound(num_std_dev); } template double hll_union_alloc::get_upper_bound(uint8_t num_std_dev) const { - if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) + if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) { static_cast*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min(); + } return gadget_.get_upper_bound(num_std_dev); } diff --git a/hll/include/coupon_iterator-internal.hpp b/hll/include/coupon_iterator-internal.hpp index 84133ffb..356517ec 100644 --- a/hll/include/coupon_iterator-internal.hpp +++ b/hll/include/coupon_iterator-internal.hpp @@ -28,7 +28,7 @@ template coupon_iterator::coupon_iterator(const uint32_t* array, size_t array_size, size_t index, bool all): array_(array), array_size_(array_size), index_(index), all_(all) { while (index_ < array_size_) { - if (all_ || array_[index_] != hll_constants::EMPTY) break; + if (all_ || array_[index_] != hll_constants::EMPTY) { break; } ++index_; } } @@ -36,7 +36,7 @@ array_(array), array_size_(array_size), index_(index), all_(all) { template coupon_iterator& coupon_iterator::operator++() { while (++index_ < array_size_) { - if (all_ || array_[index_] != hll_constants::EMPTY) break; + if (all_ || array_[index_] != hll_constants::EMPTY) { break; } } return *this; }