mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 21:18:20 +00:00
Merge remote-tracking branch 'origin/master' into topic/johanna/hash-unification
This commit is contained in:
commit
04ed125941
257 changed files with 4534 additions and 4025 deletions
|
@ -37,7 +37,7 @@ function bloomfilter_basic_init%(fp: double, capacity: count,
|
|||
if ( fp < 0.0 || fp > 1.0 )
|
||||
{
|
||||
reporter->Error("false-positive rate must take value between 0 and 1");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t cells = BasicBloomFilter::M(fp, capacity);
|
||||
|
@ -46,7 +46,7 @@ function bloomfilter_basic_init%(fp: double, capacity: count,
|
|||
name->Len());
|
||||
const Hasher* h = new DoubleHasher(optimal_k, seed);
|
||||
|
||||
return new BloomFilterVal(new BasicBloomFilter(h, cells));
|
||||
return make_intrusive<BloomFilterVal>(new BasicBloomFilter(h, cells));
|
||||
%}
|
||||
|
||||
## Creates a basic Bloom filter. This function serves as a low-level
|
||||
|
@ -74,19 +74,19 @@ function bloomfilter_basic_init2%(k: count, cells: count,
|
|||
if ( k == 0 )
|
||||
{
|
||||
reporter->Error("number of hash functions must be non-negative");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
if ( cells == 0 )
|
||||
{
|
||||
reporter->Error("number of cells must be non-negative");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hasher::seed_t seed = Hasher::MakeSeed(name->Len() > 0 ? name->Bytes() : 0,
|
||||
name->Len());
|
||||
const Hasher* h = new DoubleHasher(k, seed);
|
||||
|
||||
return new BloomFilterVal(new BasicBloomFilter(h, cells));
|
||||
return make_intrusive<BloomFilterVal>(new BasicBloomFilter(h, cells));
|
||||
%}
|
||||
|
||||
## Creates a counting Bloom filter.
|
||||
|
@ -118,7 +118,7 @@ function bloomfilter_counting_init%(k: count, cells: count, max: count,
|
|||
if ( max == 0 )
|
||||
{
|
||||
reporter->Error("max counter value must be greater than 0");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Hasher::seed_t seed = Hasher::MakeSeed(name->Len() > 0 ? name->Bytes() : 0,
|
||||
|
@ -130,7 +130,7 @@ function bloomfilter_counting_init%(k: count, cells: count, max: count,
|
|||
while ( max >>= 1 )
|
||||
++width;
|
||||
|
||||
return new BloomFilterVal(new CountingBloomFilter(h, cells, width));
|
||||
return make_intrusive<BloomFilterVal>(new CountingBloomFilter(h, cells, width));
|
||||
%}
|
||||
|
||||
## Adds an element to a Bloom filter.
|
||||
|
@ -155,7 +155,7 @@ function bloomfilter_add%(bf: opaque of bloomfilter, x: any%): any
|
|||
else
|
||||
bfv->Add(x);
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
%}
|
||||
|
||||
## Retrieves the counter for a given element in a Bloom filter.
|
||||
|
@ -174,15 +174,15 @@ function bloomfilter_lookup%(bf: opaque of bloomfilter, x: any%): count
|
|||
const BloomFilterVal* bfv = static_cast<const BloomFilterVal*>(bf);
|
||||
|
||||
if ( ! bfv->Type() )
|
||||
reporter->Error("cannot perform lookup on untyped Bloom filter");
|
||||
return val_mgr->Count(0);
|
||||
|
||||
else if ( ! same_type(bfv->Type(), x->Type()) )
|
||||
reporter->Error("incompatible Bloom filter types");
|
||||
|
||||
else
|
||||
return val_mgr->GetCount(static_cast<uint64_t>(bfv->Count(x)));
|
||||
return val_mgr->Count(static_cast<uint64_t>(bfv->Count(x)));
|
||||
|
||||
return val_mgr->GetCount(0);
|
||||
return val_mgr->Count(0);
|
||||
%}
|
||||
|
||||
## Removes all elements from a Bloom filter. This function resets all bits in
|
||||
|
@ -201,7 +201,7 @@ function bloomfilter_clear%(bf: opaque of bloomfilter%): any
|
|||
if ( bfv->Type() ) // Untyped Bloom filters are already empty.
|
||||
bfv->Clear();
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
%}
|
||||
|
||||
## Merges two Bloom filters.
|
||||
|
@ -230,10 +230,10 @@ function bloomfilter_merge%(bf1: opaque of bloomfilter,
|
|||
! same_type(bfv1->Type(), bfv2->Type()) )
|
||||
{
|
||||
reporter->Error("incompatible Bloom filter types");
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return BloomFilterVal::Merge(bfv1, bfv2).release();
|
||||
return BloomFilterVal::Merge(bfv1, bfv2);
|
||||
%}
|
||||
|
||||
## Returns a string with a representation of a Bloom filter's internal
|
||||
|
@ -245,5 +245,5 @@ function bloomfilter_merge%(bf1: opaque of bloomfilter,
|
|||
function bloomfilter_internal_state%(bf: opaque of bloomfilter%): string
|
||||
%{
|
||||
BloomFilterVal* bfv = static_cast<BloomFilterVal*>(bf);
|
||||
return new StringVal(bfv->InternalState());
|
||||
return make_intrusive<StringVal>(bfv->InternalState());
|
||||
%}
|
||||
|
|
|
@ -23,7 +23,7 @@ module GLOBAL;
|
|||
function hll_cardinality_init%(err: double, confidence: double%): opaque of cardinality
|
||||
%{
|
||||
CardinalityCounter* c = new CardinalityCounter(err, confidence);
|
||||
CardinalityVal* cv = new CardinalityVal(c);
|
||||
auto cv = make_intrusive<CardinalityVal>(c);
|
||||
|
||||
return cv;
|
||||
%}
|
||||
|
@ -45,17 +45,17 @@ function hll_cardinality_add%(handle: opaque of cardinality, elem: any%): bool
|
|||
if ( ! cv->Type() && ! cv->Typify(elem->Type()) )
|
||||
{
|
||||
reporter->Error("failed to set HLL type");
|
||||
return val_mgr->GetFalse();
|
||||
return val_mgr->False();
|
||||
}
|
||||
|
||||
else if ( ! same_type(cv->Type(), elem->Type()) )
|
||||
{
|
||||
reporter->Error("incompatible HLL data type");
|
||||
return val_mgr->GetFalse();
|
||||
return val_mgr->False();
|
||||
}
|
||||
|
||||
cv->Add(elem);
|
||||
return val_mgr->GetTrue();
|
||||
return val_mgr->True();
|
||||
%}
|
||||
|
||||
## Merges a HLL cardinality counter into another.
|
||||
|
@ -82,7 +82,7 @@ function hll_cardinality_merge_into%(handle1: opaque of cardinality, handle2: op
|
|||
! same_type(v1->Type(), v2->Type()) )
|
||||
{
|
||||
reporter->Error("incompatible HLL types");
|
||||
return val_mgr->GetFalse();
|
||||
return val_mgr->False();
|
||||
}
|
||||
|
||||
CardinalityCounter* h1 = v1->Get();
|
||||
|
@ -92,10 +92,10 @@ function hll_cardinality_merge_into%(handle1: opaque of cardinality, handle2: op
|
|||
if ( ! res )
|
||||
{
|
||||
reporter->Error("Cardinality counters with different parameters cannot be merged");
|
||||
return val_mgr->GetFalse();
|
||||
return val_mgr->False();
|
||||
}
|
||||
|
||||
return val_mgr->GetTrue();
|
||||
return val_mgr->True();
|
||||
%}
|
||||
|
||||
## Estimate the current cardinality of an HLL cardinality counter.
|
||||
|
@ -113,7 +113,7 @@ function hll_cardinality_estimate%(handle: opaque of cardinality%): double
|
|||
|
||||
double estimate = h->Size();
|
||||
|
||||
return new Val(estimate, TYPE_DOUBLE);
|
||||
return make_intrusive<Val>(estimate, TYPE_DOUBLE);
|
||||
%}
|
||||
|
||||
## Copy a HLL cardinality counter.
|
||||
|
@ -129,7 +129,7 @@ function hll_cardinality_copy%(handle: opaque of cardinality%): opaque of cardin
|
|||
CardinalityVal* cv = static_cast<CardinalityVal*>(handle);
|
||||
CardinalityCounter* h = cv->Get();
|
||||
CardinalityCounter* h2 = new CardinalityCounter(*h);
|
||||
CardinalityVal* out = new CardinalityVal(h2);
|
||||
auto out = make_intrusive<CardinalityVal>(h2);
|
||||
|
||||
return out;
|
||||
%}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
## topk_size topk_sum topk_merge topk_merge_prune
|
||||
function topk_init%(size: count%): opaque of topk
|
||||
%{
|
||||
probabilistic::TopkVal* v = new probabilistic::TopkVal(size);
|
||||
auto v = make_intrusive<probabilistic::TopkVal>(size);
|
||||
return v;
|
||||
%}
|
||||
|
||||
|
@ -36,7 +36,7 @@ function topk_add%(handle: opaque of topk, value: any%): any
|
|||
probabilistic::TopkVal* h = (probabilistic::TopkVal*) handle;
|
||||
h->Encountered(value);
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
%}
|
||||
|
||||
## Get the first *k* elements of the top-k data structure.
|
||||
|
@ -53,7 +53,7 @@ function topk_get_top%(handle: opaque of topk, k: count%): any_vec
|
|||
%{
|
||||
assert(handle);
|
||||
probabilistic::TopkVal* h = (probabilistic::TopkVal*) handle;
|
||||
return h->GetTopK(k);
|
||||
return IntrusivePtr{AdoptRef{}, h->GetTopK(k)};
|
||||
%}
|
||||
|
||||
## Get an overestimated count of how often a value has been encountered.
|
||||
|
@ -74,7 +74,7 @@ function topk_count%(handle: opaque of topk, value: any%): count
|
|||
%{
|
||||
assert(handle);
|
||||
probabilistic::TopkVal* h = (probabilistic::TopkVal*) handle;
|
||||
return val_mgr->GetCount(h->GetCount(value));
|
||||
return val_mgr->Count(h->GetCount(value));
|
||||
%}
|
||||
|
||||
## Get the maximal overestimation for count.
|
||||
|
@ -94,7 +94,7 @@ function topk_epsilon%(handle: opaque of topk, value: any%): count
|
|||
%{
|
||||
assert(handle);
|
||||
probabilistic::TopkVal* h = (probabilistic::TopkVal*) handle;
|
||||
return val_mgr->GetCount(h->GetEpsilon(value));
|
||||
return val_mgr->Count(h->GetEpsilon(value));
|
||||
%}
|
||||
|
||||
## Get the number of elements this data structure is supposed to track (given
|
||||
|
@ -113,7 +113,7 @@ function topk_size%(handle: opaque of topk%): count
|
|||
%{
|
||||
assert(handle);
|
||||
probabilistic::TopkVal* h = (probabilistic::TopkVal*) handle;
|
||||
return val_mgr->GetCount(h->GetSize());
|
||||
return val_mgr->Count(h->GetSize());
|
||||
%}
|
||||
|
||||
## Get the sum of all counts of all elements in the data structure.
|
||||
|
@ -133,7 +133,7 @@ function topk_sum%(handle: opaque of topk%): count
|
|||
%{
|
||||
assert(handle);
|
||||
probabilistic::TopkVal* h = (probabilistic::TopkVal*) handle;
|
||||
return val_mgr->GetCount(h->GetSum());
|
||||
return val_mgr->Count(h->GetSum());
|
||||
%}
|
||||
|
||||
## Merge the second top-k data structure into the first.
|
||||
|
@ -157,7 +157,7 @@ function topk_merge%(handle1: opaque of topk, handle2: opaque of topk%): any
|
|||
|
||||
h1->Merge(h2);
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
%}
|
||||
|
||||
## Merge the second top-k data structure into the first and prunes the final
|
||||
|
@ -183,5 +183,5 @@ function topk_merge_prune%(handle1: opaque of topk, handle2: opaque of topk%): a
|
|||
|
||||
h1->Merge(h2, true);
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
%}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue