Support seeding for hashers.

This commit is contained in:
Matthias Vallentin 2013-06-14 10:19:39 -07:00
parent d2d8aff814
commit 1576239f67
2 changed files with 14 additions and 1 deletions

View file

@ -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
{
HashVector h(K(), 0);

View file

@ -96,7 +96,9 @@ protected:
*/
class Hasher {
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:
// 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