mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 18:48:20 +00:00
Merge remote-tracking branch 'origin/topic/bernhard/topk' into topic/bernhard/topk
This commit is contained in:
commit
6beaefd207
1 changed files with 7 additions and 4 deletions
11
src/Topk.cc
11
src/Topk.cc
|
@ -26,12 +26,13 @@ Element::~Element()
|
||||||
HashKey* TopkVal::GetHash(Val* v) const
|
HashKey* TopkVal::GetHash(Val* v) const
|
||||||
{
|
{
|
||||||
TypeList* tl = new TypeList(v->Type());
|
TypeList* tl = new TypeList(v->Type());
|
||||||
tl->Append(v->Type());
|
tl->Append(v->Type()->Ref());
|
||||||
CompositeHash* topk_hash = new CompositeHash(tl);
|
CompositeHash* topk_hash = new CompositeHash(tl);
|
||||||
Unref(tl);
|
Unref(tl);
|
||||||
|
|
||||||
HashKey* key = topk_hash->ComputeHash(v, 1);
|
HashKey* key = topk_hash->ComputeHash(v, 1);
|
||||||
assert(key);
|
assert(key);
|
||||||
|
delete topk_hash;
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ bool TopkVal::DoSerialize(SerialInfo* info) const
|
||||||
else
|
else
|
||||||
assert(numElements == 0);
|
assert(numElements == 0);
|
||||||
|
|
||||||
int i = 0;
|
uint64_t i = 0;
|
||||||
std::list<Bucket*>::const_iterator it = buckets.begin();
|
std::list<Bucket*>::const_iterator it = buckets.begin();
|
||||||
while ( it != buckets.end() )
|
while ( it != buckets.end() )
|
||||||
{
|
{
|
||||||
|
@ -223,7 +224,7 @@ bool TopkVal::DoUnserialize(UnserialInfo* info)
|
||||||
else
|
else
|
||||||
assert(numElements == 0);
|
assert(numElements == 0);
|
||||||
|
|
||||||
int i = 0;
|
uint64_t i = 0;
|
||||||
while ( i < numElements )
|
while ( i < numElements )
|
||||||
{
|
{
|
||||||
Bucket* b = new Bucket();
|
Bucket* b = new Bucket();
|
||||||
|
@ -232,7 +233,7 @@ bool TopkVal::DoUnserialize(UnserialInfo* info)
|
||||||
v &= UNSERIALIZE(&b->count);
|
v &= UNSERIALIZE(&b->count);
|
||||||
b->bucketPos = buckets.insert(buckets.end(), b);
|
b->bucketPos = buckets.insert(buckets.end(), b);
|
||||||
|
|
||||||
for ( int j = 0; j < elements_count; j++ )
|
for ( uint64_t j = 0; j < elements_count; j++ )
|
||||||
{
|
{
|
||||||
Element* e = new Element();
|
Element* e = new Element();
|
||||||
v &= UNSERIALIZE(&e->epsilon);
|
v &= UNSERIALIZE(&e->epsilon);
|
||||||
|
@ -311,6 +312,7 @@ uint64_t TopkVal::getCount(Val* value) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete key;
|
||||||
return e->parent->count;
|
return e->parent->count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,6 +327,7 @@ uint64_t TopkVal::getEpsilon(Val* value) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete key;
|
||||||
return e->epsilon;
|
return e->epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue