re-use same hash class for all add operations

This commit is contained in:
Bernhard Amann 2013-07-30 18:48:05 -07:00
parent 18c10f3cb5
commit 83ce77e575
3 changed files with 11 additions and 14 deletions

View file

@ -771,3 +771,11 @@ BroType* CardinalityVal::Type() const
{
return type;
}
void CardinalityVal::Add(const Val* val)
{
HashKey* key = hash->ComputeHash(val, 1);
c->addElement(key->Hash());
delete key;
}

View file

@ -154,6 +154,8 @@ public:
explicit CardinalityVal(probabilistic::CardinalityCounter*);
virtual ~CardinalityVal();
void Add(const Val* val);
BroType* Type() const;
bool Typify(BroType* type);

View file

@ -54,20 +54,7 @@ function hll_cardinality_add%(handle: opaque of cardinality, elem: any%): bool
return new Val(0, TYPE_BOOL);
}
int status = 0;
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;
cv->Add(elem);
return new Val(1, TYPE_BOOL);
%}