mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Support seeding for hashers.
This commit is contained in:
parent
d2d8aff814
commit
1576239f67
2 changed files with 14 additions and 1 deletions
|
@ -74,6 +74,17 @@ bool CounterVector::DoUnserialize(UnserialInfo* info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HashPolicy::Hasher::Hasher(size_t seed)
|
||||||
|
: h3_(seed)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
HashPolicy::HashType
|
||||||
|
HashPolicy::Hasher::operator()(const void* x, size_t n) const
|
||||||
|
{
|
||||||
|
return h3_(x, n);
|
||||||
|
}
|
||||||
|
|
||||||
HashPolicy::HashVector DefaultHashing::Hash(const void* x, size_t n) const
|
HashPolicy::HashVector DefaultHashing::Hash(const void* x, size_t n) const
|
||||||
{
|
{
|
||||||
HashVector h(K(), 0);
|
HashVector h(K(), 0);
|
||||||
|
|
|
@ -96,7 +96,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
class Hasher {
|
class Hasher {
|
||||||
public:
|
public:
|
||||||
HashType operator()(const void* x, size_t n) const { return h3_(x, n); }
|
Hasher(size_t seed);
|
||||||
|
|
||||||
|
HashType operator()(const void* x, size_t n) const;
|
||||||
private:
|
private:
|
||||||
// FIXME: The hardcoded value of 36 comes from UHASH_KEY_SIZE defined in
|
// FIXME: The hardcoded value of 36 comes from UHASH_KEY_SIZE defined in
|
||||||
// Hash.h. I do not know how this value impacts the hash function behavior
|
// Hash.h. I do not know how this value impacts the hash function behavior
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue