apache/datasketches-cpp

kll_sketch throw exception when number of inserted data is small

Closed this issue · 1 comments

#include <iostream>
#include <kll_sketch.hpp>
using namespace datasketches;
using namespace std;

int main()
{
    using T = int8_t;
    kll_sketch<T> kll;
    int N = 3;
    kll.update(-8);
    kll.update(-8);
    kll.update(-8);
    
    auto blob = kll.serialize();
    std::cout << "blobsize=" <<  blob.size() << std::endl;
    auto kll2 = kll_sketch<T>::deserialize(blob.data(), blob.size());
    return 0;
}

will lead to

libc++abi: terminating with uncaught exception of type std::out_of_range: Insufficient buffer size detected: bytes available 29, minimum needed 32

Seems that ensure_minimum_memory(size, 1ULL << preamble_ints); at kll_sketch_impl.hpp:578 is incorrect.

A fix has been merged and we have started the vote process for a 3.2.0 release (which includes some changes to python, otherwise it'd be a patch release). It'll be a few days before the release is final, even if no issues with the release candidate, but there's no additional work needed on this issue.