mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
re-use same hash class for all add operations
This commit is contained in:
parent
18c10f3cb5
commit
83ce77e575
3 changed files with 11 additions and 14 deletions
|
@ -771,3 +771,11 @@ BroType* CardinalityVal::Type() const
|
||||||
{
|
{
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardinalityVal::Add(const Val* val)
|
||||||
|
{
|
||||||
|
HashKey* key = hash->ComputeHash(val, 1);
|
||||||
|
c->addElement(key->Hash());
|
||||||
|
delete key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,8 @@ public:
|
||||||
explicit CardinalityVal(probabilistic::CardinalityCounter*);
|
explicit CardinalityVal(probabilistic::CardinalityCounter*);
|
||||||
virtual ~CardinalityVal();
|
virtual ~CardinalityVal();
|
||||||
|
|
||||||
|
void Add(const Val* val);
|
||||||
|
|
||||||
BroType* Type() const;
|
BroType* Type() const;
|
||||||
bool Typify(BroType* type);
|
bool Typify(BroType* type);
|
||||||
|
|
||||||
|
|
|
@ -54,20 +54,7 @@ function hll_cardinality_add%(handle: opaque of cardinality, elem: any%): bool
|
||||||
return new Val(0, TYPE_BOOL);
|
return new Val(0, TYPE_BOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int status = 0;
|
cv->Add(elem);
|
||||||
|
|
||||||
TypeList* tl = new TypeList(elem->Type());
|
|
||||||
tl->Append(elem->Type());
|
|
||||||
CompositeHash* hll_hash = new CompositeHash(tl);
|
|
||||||
Unref(tl);
|
|
||||||
|
|
||||||
HashKey* key = hll_hash->ComputeHash(elem, 1);
|
|
||||||
uint64_t hash = key->Hash();
|
|
||||||
|
|
||||||
CardinalityCounter* h = cv->Get();
|
|
||||||
h->addElement(hash);
|
|
||||||
|
|
||||||
delete hll_hash;
|
|
||||||
return new Val(1, TYPE_BOOL);
|
return new Val(1, TYPE_BOOL);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue