mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Merge remote-tracking branch 'origin/master' into topic/johanna/bloomfilter
This commit is contained in:
commit
42bc6db359
377 changed files with 11627 additions and 8961 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <broker/data.hh>
|
||||
#include <openssl/sha.h>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
|
||||
#include "zeek/digest.h"
|
||||
|
@ -512,12 +513,12 @@ broker::expected<broker::data> BitVector::Serialize() const
|
|||
|
||||
std::unique_ptr<BitVector> BitVector::Unserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
auto v = broker::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() >= 2) )
|
||||
return nullptr;
|
||||
|
||||
auto num_bits = caf::get_if<uint64_t>(&(*v)[0]);
|
||||
auto size = caf::get_if<uint64_t>(&(*v)[1]);
|
||||
auto num_bits = broker::get_if<uint64_t>(&(*v)[0]);
|
||||
auto size = broker::get_if<uint64_t>(&(*v)[1]);
|
||||
|
||||
if ( ! (num_bits && size) )
|
||||
return nullptr;
|
||||
|
@ -530,7 +531,7 @@ std::unique_ptr<BitVector> BitVector::Unserialize(const broker::data& data)
|
|||
|
||||
for ( size_t i = 0; i < *size; ++i )
|
||||
{
|
||||
auto x = caf::get_if<uint64_t>(&(*v)[2 + i]);
|
||||
auto x = broker::get_if<uint64_t>(&(*v)[2 + i]);
|
||||
if ( ! x )
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@ broker::expected<broker::data> BloomFilter::Serialize() const
|
|||
|
||||
std::unique_ptr<BloomFilter> BloomFilter::Unserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
auto v = broker::get_if<broker::vector>(&data);
|
||||
|
||||
if ( ! (v && v->size() == 3) )
|
||||
return nullptr;
|
||||
|
||||
auto type = caf::get_if<uint64_t>(&(*v)[0]);
|
||||
auto type = broker::get_if<uint64_t>(&(*v)[0]);
|
||||
if ( ! type )
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -212,13 +212,13 @@ broker::expected<broker::data> CardinalityCounter::Serialize() const
|
|||
|
||||
std::unique_ptr<CardinalityCounter> CardinalityCounter::Unserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
auto v = broker::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() >= 3) )
|
||||
return nullptr;
|
||||
|
||||
auto m = caf::get_if<uint64_t>(&(*v)[0]);
|
||||
auto V = caf::get_if<uint64_t>(&(*v)[1]);
|
||||
auto alpha_m = caf::get_if<double>(&(*v)[2]);
|
||||
auto m = broker::get_if<uint64_t>(&(*v)[0]);
|
||||
auto V = broker::get_if<uint64_t>(&(*v)[1]);
|
||||
auto alpha_m = broker::get_if<double>(&(*v)[2]);
|
||||
|
||||
if ( ! (m && V && alpha_m) )
|
||||
return nullptr;
|
||||
|
@ -233,7 +233,7 @@ std::unique_ptr<CardinalityCounter> CardinalityCounter::Unserialize(const broker
|
|||
|
||||
for ( size_t i = 0; i < *m; ++i )
|
||||
{
|
||||
auto x = caf::get_if<uint64_t>(&(*v)[3 + i]);
|
||||
auto x = broker::get_if<uint64_t>(&(*v)[3 + i]);
|
||||
if ( ! x )
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -187,11 +187,11 @@ broker::expected<broker::data> CounterVector::Serialize() const
|
|||
|
||||
std::unique_ptr<CounterVector> CounterVector::Unserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
auto v = broker::get_if<broker::vector>(&data);
|
||||
if ( ! (v && v->size() >= 2) )
|
||||
return nullptr;
|
||||
|
||||
auto width = caf::get_if<uint64_t>(&(*v)[0]);
|
||||
auto width = broker::get_if<uint64_t>(&(*v)[0]);
|
||||
auto bits = BitVector::Unserialize((*v)[1]);
|
||||
|
||||
if ( ! (width && bits) )
|
||||
|
|
|
@ -158,13 +158,13 @@ public:
|
|||
protected:
|
||||
friend CounterVector operator|(const CounterVector& x, const CounterVector& y);
|
||||
|
||||
CounterVector() { }
|
||||
CounterVector() = default;
|
||||
|
||||
private:
|
||||
CounterVector& operator=(const CounterVector&); // Disable.
|
||||
|
||||
BitVector* bits;
|
||||
size_t width;
|
||||
BitVector* bits = nullptr;
|
||||
size_t width = 0;
|
||||
};
|
||||
|
||||
} // namespace zeek::probabilistic::detail
|
||||
|
|
|
@ -60,15 +60,15 @@ broker::expected<broker::data> Hasher::Serialize() const
|
|||
|
||||
std::unique_ptr<Hasher> Hasher::Unserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
auto v = broker::get_if<broker::vector>(&data);
|
||||
|
||||
if ( ! (v && v->size() == 4) )
|
||||
return nullptr;
|
||||
|
||||
auto type = caf::get_if<uint64_t>(&(*v)[0]);
|
||||
auto k = caf::get_if<uint64_t>(&(*v)[1]);
|
||||
auto h1 = caf::get_if<uint64_t>(&(*v)[2]);
|
||||
auto h2 = caf::get_if<uint64_t>(&(*v)[3]);
|
||||
auto type = broker::get_if<uint64_t>(&(*v)[0]);
|
||||
auto k = broker::get_if<uint64_t>(&(*v)[1]);
|
||||
auto h1 = broker::get_if<uint64_t>(&(*v)[2]);
|
||||
auto h2 = broker::get_if<uint64_t>(&(*v)[3]);
|
||||
|
||||
if ( ! (type && k && h1 && h2) )
|
||||
return nullptr;
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
* @param data A pointer to contiguous data that should be crunched into a
|
||||
* seed. If 0, the function tries to find a global_hash_seed script variable
|
||||
* to derive a seed from. If this variable does not exist, the function uses
|
||||
* the initial seed generated at Bro startup.
|
||||
* the initial seed generated at Zeek startup.
|
||||
*
|
||||
* @param size The number of bytes of *data*.
|
||||
*
|
||||
|
@ -148,7 +148,7 @@ public:
|
|||
|
||||
/**
|
||||
* Constructs an hash function seeded with a given seed and an
|
||||
* optional extra seed to replace the initial Bro seed.
|
||||
* optional extra seed to replace the initial Zeek seed.
|
||||
*
|
||||
* @param arg_seed The seed to use for this instance.
|
||||
*/
|
||||
|
|
|
@ -447,14 +447,14 @@ broker::expected<broker::data> TopkVal::DoSerialize() const
|
|||
|
||||
bool TopkVal::DoUnserialize(const broker::data& data)
|
||||
{
|
||||
auto v = caf::get_if<broker::vector>(&data);
|
||||
auto v = broker::get_if<broker::vector>(&data);
|
||||
|
||||
if ( ! (v && v->size() >= 4) )
|
||||
return false;
|
||||
|
||||
auto size_ = caf::get_if<uint64_t>(&(*v)[0]);
|
||||
auto numElements_ = caf::get_if<uint64_t>(&(*v)[1]);
|
||||
auto pruned_ = caf::get_if<bool>(&(*v)[2]);
|
||||
auto size_ = broker::get_if<uint64_t>(&(*v)[0]);
|
||||
auto numElements_ = broker::get_if<uint64_t>(&(*v)[1]);
|
||||
auto pruned_ = broker::get_if<bool>(&(*v)[2]);
|
||||
|
||||
if ( ! (size_ && numElements_ && pruned_) )
|
||||
return false;
|
||||
|
@ -463,7 +463,7 @@ bool TopkVal::DoUnserialize(const broker::data& data)
|
|||
numElements = *numElements_;
|
||||
pruned = *pruned_;
|
||||
|
||||
auto no_type = caf::get_if<broker::none>(&(*v)[3]);
|
||||
auto no_type = broker::get_if<broker::none>(&(*v)[3]);
|
||||
if ( ! no_type )
|
||||
{
|
||||
auto t = UnserializeType((*v)[3]);
|
||||
|
@ -479,8 +479,8 @@ bool TopkVal::DoUnserialize(const broker::data& data)
|
|||
|
||||
while ( i < numElements )
|
||||
{
|
||||
auto elements_count = caf::get_if<uint64_t>(&(*v)[idx++]);
|
||||
auto count = caf::get_if<uint64_t>(&(*v)[idx++]);
|
||||
auto elements_count = broker::get_if<uint64_t>(&(*v)[idx++]);
|
||||
auto count = broker::get_if<uint64_t>(&(*v)[idx++]);
|
||||
|
||||
if ( ! (elements_count && count) )
|
||||
return false;
|
||||
|
@ -491,7 +491,7 @@ bool TopkVal::DoUnserialize(const broker::data& data)
|
|||
|
||||
for ( uint64_t j = 0; j < *elements_count; j++ )
|
||||
{
|
||||
auto epsilon = caf::get_if<uint64_t>(&(*v)[idx++]);
|
||||
auto epsilon = broker::get_if<uint64_t>(&(*v)[idx++]);
|
||||
auto val = Broker::detail::data_to_val((*v)[idx++], type.get());
|
||||
|
||||
if ( ! (epsilon && val) )
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
/**
|
||||
* Call this when a new value is encountered. Note that on the first
|
||||
* call, the Bro type of the value types that are counted is set. All
|
||||
* call, the Zeek type of the value types that are counted is set. All
|
||||
* following calls to encountered have to specify the same type.
|
||||
*
|
||||
* @param value The encountered element
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
* certain val. Returns 0 if the val is unknown (and logs the error
|
||||
* to reporter).
|
||||
*
|
||||
* @param value Bro value to get counts for
|
||||
* @param value Zeek value to get counts for
|
||||
*
|
||||
* @returns internal count for val, 0 if unknown
|
||||
*/
|
||||
|
@ -91,7 +91,7 @@ public:
|
|||
* Get the current epsilon tracked in the top-k data structure for a
|
||||
* certain val.
|
||||
*
|
||||
* @param value Bro value to get epsilons for
|
||||
* @param value Zeek value to get epsilons for
|
||||
*
|
||||
* @returns the epsilon. Returns 0 if the val is unknown (and logs
|
||||
* the error to reporter)
|
||||
|
@ -171,12 +171,12 @@ private:
|
|||
void Typify(TypePtr t);
|
||||
|
||||
TypePtr type;
|
||||
zeek::detail::CompositeHash* hash;
|
||||
zeek::detail::CompositeHash* hash = nullptr;
|
||||
std::list<Bucket*> buckets;
|
||||
PDict<Element>* elementDict;
|
||||
uint64_t size; // how many elements are we tracking?
|
||||
uint64_t numElements; // how many elements do we have at the moment
|
||||
bool pruned; // was this data structure pruned?
|
||||
PDict<Element>* elementDict = nullptr;
|
||||
uint64_t size = 0; // how many elements are we tracking?
|
||||
uint64_t numElements = 0; // how many elements do we have at the moment
|
||||
bool pruned = false; // was this data structure pruned?
|
||||
};
|
||||
|
||||
} // namespace zeek::probabilistic::detail
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue