stojkomilos commented on code in PR #569:
URL: https://github.com/apache/datasketches-cpp/pull/569#discussion_r4604224313
##########
kll/include/kll_sketch_impl.hpp:
##########
@@ -206,7 +206,14 @@ void kll_sketch<T, C, A>::update_min_max(const T& item) {
template<typename T, typename C, typename A>
void kll_sketch<T, C, A>::reserve() {
- allocate_items();
+ if (items_ == nullptr) {
+ // nothing is stored yet, so the buffer can start at its full size
+ items_ = allocator_.allocate(k_);
+ items_size_ = k_;
+ levels_[0] = levels_[1] = k_;
+ } else if (num_levels_ == 1 && items_size_ < k_) {
+ grow_items(k_); // the buffer is still growing: grow it to its full size
in one step
Review Comment:
Done, also added test that would have caught this.
--
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]