mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
Implement value merging.
The actual BloomFilter merging still lacks, this is just the first step in the right direction from the user interface side.
This commit is contained in:
parent
22afbe42dd
commit
14a701a237
4 changed files with 54 additions and 25 deletions
|
@ -124,9 +124,7 @@ BloomFilter* BloomFilter::Unserialize(UnserialInfo* info)
|
|||
bool BloomFilter::DoSerialize(SerialInfo* info) const
|
||||
{
|
||||
DO_SERIALIZE(SER_BLOOMFILTER, SerialObj);
|
||||
if ( ! SERIALIZE(static_cast<uint16>(hash_->K())) )
|
||||
return false;
|
||||
return SERIALIZE(static_cast<uint64>(elements_));
|
||||
return SERIALIZE(static_cast<uint16>(hash_->K()));
|
||||
}
|
||||
|
||||
bool BloomFilter::DoUnserialize(UnserialInfo* info)
|
||||
|
@ -136,10 +134,6 @@ bool BloomFilter::DoUnserialize(UnserialInfo* info)
|
|||
if ( ! UNSERIALIZE(&k) )
|
||||
return false;
|
||||
hash_ = new hash_policy(static_cast<size_t>(k));
|
||||
uint64 elements;
|
||||
if ( ! UNSERIALIZE(&elements) )
|
||||
return false;
|
||||
elements_ = static_cast<size_t>(elements);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -155,6 +149,17 @@ size_t BasicBloomFilter::K(size_t cells, size_t capacity)
|
|||
return std::ceil(frac * std::log(2));
|
||||
}
|
||||
|
||||
BasicBloomFilter* BasicBloomFilter::Merge(const BasicBloomFilter* x,
|
||||
const BasicBloomFilter* y)
|
||||
{
|
||||
BasicBloomFilter* result = new BasicBloomFilter();
|
||||
result->bits_ = new BitVector(*x->bits_ | *y->bits_);
|
||||
// TODO: implement the hasher pool and make sure the new result gets the same
|
||||
// number of (equal) hash functions.
|
||||
//assert(x->hash_ == y->hash_);
|
||||
return result;
|
||||
}
|
||||
|
||||
BasicBloomFilter::BasicBloomFilter()
|
||||
: bits_(NULL)
|
||||
{
|
||||
|
@ -201,6 +206,14 @@ size_t BasicBloomFilter::CountImpl(const HashPolicy::HashVector& h) const
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
CountingBloomFilter* CountingBloomFilter::Merge(const CountingBloomFilter* x,
|
||||
const CountingBloomFilter* y)
|
||||
{
|
||||
assert(! "not yet implemented");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CountingBloomFilter::CountingBloomFilter()
|
||||
: cells_(NULL)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue