stojkomilos commented on code in PR #569:
URL: https://github.com/apache/datasketches-cpp/pull/569#discussion_r4535259906
##########
kll/include/kll_sketch_impl.hpp:
##########
@@ -753,6 +767,21 @@ void kll_sketch<T, C,
A>::add_empty_top_level_to_completely_full_sketch() {
levels_[num_levels_] = new_total_cap; // initialize the new "extra" index at
the top
}
+// Grows the items buffer of a one-level sketch when it is full and smaller
than k.
+// Compaction starts only when the buffer is full at k items, so growing does
not change the result.
+template<typename T, typename C, typename A>
+void kll_sketch<T, C, A>::grow_items() {
Review Comment:
Ah okay, valid.
Although I don't think I should do this in this PR but in a followup.
Reason: this bug is also present on master right now, although it's triggered
on compaction rather than grow_items. See this example that fails on master
```cpp
TEST_CASE("kll sketch: update with aliased item during compaction",
"[kll_sketch]") {
const uint16_t k = 200;
kll_sketch<std::string> sketch(k);
const std::string& item = sketch.begin()->first;
const std::string expected = item;
// Triggers compaction
sketch.update(item);
REQUIRE(sketch.get_n() == kll_constants::DEFAULT_K + 1);
uint32_t count = 0;
for (const auto& entry : sketch) {
if (entry.first == expected) {
++count;
}
}
REQUIRE(count == 2);
}
```
I already have a draft PR for this (fixes both master bug and current bug,
not ready for review yet).
--
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]