Move all of the hashing classes/functions to zeek::detail namespace

This commit is contained in:
Tim Wojtulewicz 2020-07-21 13:34:17 -07:00
parent 93948b4d19
commit a2a435360a
40 changed files with 289 additions and 234 deletions

View file

@ -23,10 +23,10 @@ void TopkVal::Typify(zeek::TypePtr t)
type = std::move(t);
auto tl = zeek::make_intrusive<zeek::TypeList>(type);
tl->Append(type);
hash = new CompositeHash(std::move(tl));
hash = new zeek::detail::CompositeHash(std::move(tl));
}
HashKey* TopkVal::GetHash(Val* v) const
zeek::detail::HashKey* TopkVal::GetHash(Val* v) const
{
auto key = hash->MakeHashKey(*v, true);
assert(key);
@ -103,7 +103,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune)
{
Element* e = *eit;
// lookup if we already know this one...
HashKey* key = GetHash(e->value);
zeek::detail::HashKey* key = GetHash(e->value);
Element* olde = (Element*) elementDict->Lookup(key);
if ( olde == nullptr )
@ -158,7 +158,7 @@ void TopkVal::Merge(const TopkVal* value, bool doPrune)
assert(b->elements.size() > 0);
Element* e = b->elements.front();
HashKey* key = GetHash(e->value);
zeek::detail::HashKey* key = GetHash(e->value);
elementDict->RemoveEntry(key);
delete key;
delete e;
@ -222,7 +222,7 @@ zeek::VectorValPtr TopkVal::GetTopK(int k) const // returns vector
uint64_t TopkVal::GetCount(Val* value) const
{
HashKey* key = GetHash(value);
zeek::detail::HashKey* key = GetHash(value);
Element* e = (Element*) elementDict->Lookup(key);
delete key;
@ -237,7 +237,7 @@ uint64_t TopkVal::GetCount(Val* value) const
uint64_t TopkVal::GetEpsilon(Val* value) const
{
HashKey* key = GetHash(value);
zeek::detail::HashKey* key = GetHash(value);
Element* e = (Element*) elementDict->Lookup(key);
delete key;
@ -282,7 +282,7 @@ void TopkVal::Encountered(zeek::ValPtr encountered)
}
// Step 1 - get the hash.
HashKey* key = GetHash(encountered);
zeek::detail::HashKey* key = GetHash(encountered);
Element* e = (Element*) elementDict->Lookup(key);
if ( e == nullptr )
@ -326,7 +326,7 @@ void TopkVal::Encountered(zeek::ValPtr encountered)
// evict oldest element with least hits.
assert(b->elements.size() > 0);
HashKey* deleteKey = GetHash((*(b->elements.begin()))->value);
zeek::detail::HashKey* deleteKey = GetHash((*(b->elements.begin()))->value);
b->elements.erase(b->elements.begin());
Element* deleteElement = (Element*) elementDict->RemoveEntry(deleteKey);
assert(deleteElement); // there has to have been a minimal element...
@ -506,7 +506,7 @@ bool TopkVal::DoUnserialize(const broker::data& data)
b->elements.insert(b->elements.end(), e);
HashKey* key = GetHash(e->value);
zeek::detail::HashKey* key = GetHash(e->value);
assert (elementDict->Lookup(key) == nullptr);
elementDict->Insert(key, e);