Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions hll/include/CouponHashSet-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ CouponHashSet<A>* CouponHashSet<A>::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();
}
Expand Down
3 changes: 1 addition & 2 deletions hll/include/CouponList-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ CouponList<A>* CouponList<A>::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();
}
Expand Down
6 changes: 3 additions & 3 deletions hll/include/CubicInterpolation-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<A>(xArr, m, r, x));
else return (recursiveFindStraddle<A>(xArr, l, m, x));
if (xArr[m] <= x) { return (recursiveFindStraddle<A>(xArr, m, r, x)); }
else { return (recursiveFindStraddle<A>(xArr, l, m, x)); }
}


Expand Down
2 changes: 1 addition & 1 deletion hll/include/Hll4Array-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ uint8_t Hll4Array<A>::getSlot(uint32_t slotNo) const {

template<typename A>
uint8_t Hll4Array<A>::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);
}

Expand Down
16 changes: 8 additions & 8 deletions hll/include/HllArray-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,16 @@ HllArray<A>* HllArray<A>::newHll(const void* bytes, size_t len, const A& allocat
HllArray<A>* sketch = HllSketchImplFactory<A>::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<A>*)sketch)->putAuxHashMap(auxHashMap);
}

aux_ptr.release();
return sketch;
Expand Down Expand Up @@ -193,7 +194,7 @@ HllArray<A>* HllArray<A>::newHll(std::istream& is, const A& allocator) {
const auto hip = read<double>(is);
const auto kxq0 = read<double>(is);
const auto kxq1 = read<double>(is);
if (!oooFlag) sketch->putHipAccum(hip);
if (!oooFlag) { sketch->putHipAccum(hip); }
sketch->putKxQ0(kxq0);
sketch->putKxQ1(kxq1);

Expand All @@ -209,8 +210,7 @@ HllArray<A>* HllArray<A>::newHll(std::istream& is, const A& allocator) {
((Hll4Array<A>*)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();
}
Expand Down Expand Up @@ -545,7 +545,7 @@ template<typename A>
void HllArray<A>::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]; }
Expand Down Expand Up @@ -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_;
}
}
Expand All @@ -657,7 +657,7 @@ template<typename A>
typename HllArray<A>::const_iterator& HllArray<A>::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;
}
Expand Down
16 changes: 10 additions & 6 deletions hll/include/HllUnion-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ hll_sketch_alloc<A> hll_union_alloc<A>::get_result(target_hll_type target_type)

template<typename A>
void hll_union_alloc<A>::update(const hll_sketch_alloc<A>& sketch) {
if (sketch.is_empty()) return;
if (sketch.is_empty()) { return; }
union_impl(sketch, lg_max_k_);
}

template<typename A>
void hll_union_alloc<A>::update(hll_sketch_alloc<A>&& 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);
Expand Down Expand Up @@ -131,29 +131,33 @@ void hll_union_alloc<A>::coupon_update(uint32_t coupon) {

template<typename A>
double hll_union_alloc<A>::get_estimate() const {
if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL)
if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) {
static_cast<HllArray<A>*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min();
}
return gadget_.get_estimate();
}

template<typename A>
double hll_union_alloc<A>::get_composite_estimate() const {
if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL)
if (gadget_.sketch_impl->getCurMode() == hll_mode::HLL) {
static_cast<HllArray<A>*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min();
}
return gadget_.get_composite_estimate();
}

template<typename A>
double hll_union_alloc<A>::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<HllArray<A>*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min();
}
return gadget_.get_lower_bound(num_std_dev);
}

template<typename A>
double hll_union_alloc<A>::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<HllArray<A>*>(gadget_.sketch_impl)->check_rebuild_kxq_cur_min();
}
return gadget_.get_upper_bound(num_std_dev);
}

Expand Down
4 changes: 2 additions & 2 deletions hll/include/coupon_iterator-internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ template<typename A>
coupon_iterator<A>::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_;
}
}

template<typename A>
coupon_iterator<A>& coupon_iterator<A>::operator++() {
while (++index_ < array_size_) {
if (all_ || array_[index_] != hll_constants::EMPTY) break;
if (all_ || array_[index_] != hll_constants::EMPTY) { break; }
}
return *this;
}
Expand Down