2017-08-23 00:36:49 +02:00
|
|
|
/*
|
|
|
|
* Utilities for working with hash values.
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 2017, PostgreSQL Global Development Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HASHUTILS_H
|
|
|
|
#define HASHUTILS_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Combine two hash values, resulting in another hash value, with decent bit
|
|
|
|
* mixing.
|
|
|
|
*
|
|
|
|
* Similar to boost's hash_combine().
|
|
|
|
*/
|
|
|
|
static inline uint32
|
|
|
|
hash_combine(uint32 a, uint32 b)
|
|
|
|
{
|
|
|
|
a ^= b + 0x9e3779b9 + (a << 6) + (a >> 2);
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2017-09-22 22:38:42 +02:00
|
|
|
|
|
|
|
/*
|
2017-09-30 00:52:55 +02:00
|
|
|
* Simple inline murmur hash implementation hashing a 32 bit integer, for
|
2017-09-22 22:38:42 +02:00
|
|
|
* performance.
|
|
|
|
*/
|
|
|
|
static inline uint32
|
|
|
|
murmurhash32(uint32 data)
|
|
|
|
{
|
|
|
|
uint32 h = data;
|
|
|
|
|
|
|
|
h ^= h >> 16;
|
|
|
|
h *= 0x85ebca6b;
|
|
|
|
h ^= h >> 13;
|
|
|
|
h *= 0xc2b2ae35;
|
|
|
|
h ^= h >> 16;
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2017-08-23 00:36:49 +02:00
|
|
|
#endif /* HASHUTILS_H */
|