Skip to content
Permalink
Browse files
updates to reduce warnings
  • Loading branch information
jmalkin committed Mar 26, 2022
1 parent da15290 commit 4813ab62a726cdad2df44cdcb32445e30795c77a
Showing 3 changed files with 13 additions and 13 deletions.
@@ -519,7 +519,7 @@ class quantiles_sketch {
* @param starting_bit the zero-based starting bit position. Only the low 6 bits are used.
* @return the zero-based bit position of the lowest zero bit starting at <i>startingBit</i>.
*/
static int lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit);
static uint8_t lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit);

// implementations for floating point types
template<typename TT = T, typename std::enable_if<std::is_floating_point<TT>::value, int>::type = 0>
@@ -583,10 +583,10 @@ class quantiles_sketch<T, C, A>::const_iterator: public std::iterator<std::input
std::vector<Level, AllocLevel> levels_;
int level_;
uint32_t index_;
uint16_t k_;
uint16_t bb_count_;
uint32_t bb_count_;
uint64_t bit_pattern_;
uint64_t weight_;
uint16_t k_;
const_iterator(const Level& base_buffer, const std::vector<Level, AllocLevel>& levels, uint16_t k, uint64_t n, bool is_end);
};

@@ -193,12 +193,12 @@ void quantiles_sketch<T, C, A>::serialize(std::ostream& os, const SerDe& serde)
serde.serialize(os, max_value_, 1);

// base buffer items
serde.serialize(os, base_buffer_.data(), base_buffer_.size());
serde.serialize(os, base_buffer_.data(), static_cast<unsigned>(base_buffer_.size()));

// levels, only when data is present
for (Level lvl : levels_) {
if (lvl.size() > 0)
serde.serialize(os, lvl.data(), lvl.size());
serde.serialize(os, lvl.data(), static_cast<unsigned>(lvl.size()));
}
}
}
@@ -238,12 +238,12 @@ auto quantiles_sketch<T, C, A>::serialize(unsigned header_size_bytes, const SerD

// base buffer items
if (base_buffer_.size() > 0)
ptr += serde.serialize(ptr, end_ptr - ptr, base_buffer_.data(), base_buffer_.size());
ptr += serde.serialize(ptr, end_ptr - ptr, base_buffer_.data(), static_cast<unsigned>(base_buffer_.size()));

// levels, only when data is present
for (Level lvl : levels_) {
if (lvl.size() > 0)
ptr += serde.serialize(ptr, end_ptr - ptr, lvl.data(), lvl.size());
ptr += serde.serialize(ptr, end_ptr - ptr, lvl.data(), static_cast<unsigned>(lvl.size()));
}
}

@@ -602,7 +602,7 @@ auto quantiles_sketch<T, C, A>::get_quantile_calculator() const -> QuantileCalcu
calculator_deleter(ac)
);

uint64_t lg_weight = 0;
uint8_t lg_weight = 0;
quantile_calculator_ptr->add(base_buffer_.data(), base_buffer_.data() + base_buffer_.size(), lg_weight);
for (auto& level : levels_) {
++lg_weight;
@@ -928,7 +928,7 @@ void quantiles_sketch<T, C, A>::merge_two_size_k_buffers(Level& src_1, Level& sr
}

template<typename T, typename C, typename A>
int quantiles_sketch<T, C, A>::lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit) {
uint8_t quantiles_sketch<T, C, A>::lowest_zero_bit_starting_at(uint64_t bits, uint8_t starting_bit) {
uint8_t pos = starting_bit & 0X3F;
uint64_t my_bits = bits >> pos;

@@ -987,18 +987,18 @@ base_buffer_(base_buffer),
levels_(levels),
level_(-1),
index_(0),
k_(k),
bb_count_(compute_base_buffer_items(k, n)),
bit_pattern_(compute_bit_pattern(k, n)),
weight_(1)
weight_(1),
k_(k)
{
if (is_end) {
// if exact mode: index_ = n is end
// if sampling, level_ = max_level + 1 and index_ = 0 is end
if (bit_pattern_ == 0) // only a valid check for exact mode in constructor
index_ = static_cast<uint32_t>(n);
else
level_ = levels_.size();
level_ = static_cast<int>(levels_.size());
} else { // find first non-empty item
if (bb_count_ == 0 && bit_pattern_ > 0) {
level_ = 0;
@@ -78,7 +78,7 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {

SECTION("get bad quantile") {
quantiles_float_sketch sketch(200, 0);
sketch.update(0); // has to be non-empty to reach the check
sketch.update(0.0); // has to be non-empty to reach the check
REQUIRE_THROWS_AS(sketch.get_quantile(-1), std::invalid_argument);
}

0 comments on commit 4813ab6

Please sign in to comment.