Integrate review feedback

This commit is contained in:
Dominik Charousset 2023-12-04 15:21:58 +01:00
parent 647fdf7737
commit a69928d977
6 changed files with 52 additions and 37 deletions

View file

@ -191,10 +191,10 @@ std::unique_ptr<CardinalityCounter> CardinalityCounter::Unserialize(BrokerDataVi
return nullptr;
auto v = data.ToList();
if ( v.Size() < 3 || ! IsCount(v[0], v[1]) || ! v[2].IsReal() )
if ( v.Size() < 3 || ! are_all_counts(v[0], v[1]) || ! v[2].IsReal() )
return nullptr;
auto [m, V] = ToCount(v[0], v[1]);
auto [m, V] = to_count(v[0], v[1]);
auto alpha_m = v[2].ToReal();
if ( v.Size() != 3 + m )

View file

@ -61,10 +61,10 @@ std::unique_ptr<Hasher> Hasher::Unserialize(BrokerDataView data) {
auto v = data.ToList();
if ( v.Size() != 4 || ! IsCount(v[0], v[1], v[2], v[3]) )
if ( v.Size() != 4 || ! are_all_counts(v[0], v[1], v[2], v[3]) )
return nullptr;
auto [type, k, h1, h2] = ToCount(v[0], v[1], v[2], v[3]);
auto [type, k, h1, h2] = to_count(v[0], v[1], v[2], v[3]);
std::unique_ptr<Hasher> hasher;

View file

@ -423,6 +423,9 @@ bool TopkVal::DoUnserialize(BrokerDataView data) {
bool ok = true;
auto index = size_t{4}; // Index into v.
auto atEnd = [&v, &index] { return index >= v.Size(); };
// Returns the element at the given index in v, if that element is a count.
// If so, ok becomes true, and the index gets incremented.
// If not, ok becomes false, and the index remains unchanged.
auto nextCount = [&v, &ok, &index]() -> uint64_t {
if ( index >= v.Size() || ! v[index].IsCount() ) {
ok = false;