diff options
author | Andres Freund <andres@anarazel.de> | 2017-09-22 13:38:42 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2017-09-22 13:38:42 -0700 |
commit | 791961f59b792fbd4f0a992d3ccab47298e79103 (patch) | |
tree | 8eb4469520123ab92a19e11379f05d3fc617f364 /src/backend | |
parent | 91ad8b416cee753eaa6f520ee2d21c2d41853381 (diff) | |
download | postgresql-791961f59b792fbd4f0a992d3ccab47298e79103.tar.gz postgresql-791961f59b792fbd4f0a992d3ccab47298e79103.zip |
Add inline murmurhash32(uint32) function.
The function already existed in tidbitmap.c but more users requiring
fast hashing of 32bit ints are coming up.
Author: Andres Freund
Discussion: https://postgr.es/m/20170914061207.zxotvyopetm7lrrp@alap3.anarazel.de
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/nodes/tidbitmap.c | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c index c4e53adb0ca..01d6bc5c118 100644 --- a/src/backend/nodes/tidbitmap.c +++ b/src/backend/nodes/tidbitmap.c @@ -45,6 +45,7 @@ #include "nodes/tidbitmap.h" #include "storage/lwlock.h" #include "utils/dsa.h" +#include "utils/hashutils.h" /* * The maximum number of tuples per page is not large (typically 256 with @@ -237,30 +238,13 @@ static int tbm_comparator(const void *left, const void *right); static int tbm_shared_comparator(const void *left, const void *right, void *arg); -/* - * Simple inline murmur hash implementation for the exact width required, for - * performance. - */ -static inline uint32 -hash_blockno(BlockNumber b) -{ - uint32 h = b; - - h ^= h >> 16; - h *= 0x85ebca6b; - h ^= h >> 13; - h *= 0xc2b2ae35; - h ^= h >> 16; - return h; -} - /* define hashtable mapping block numbers to PagetableEntry's */ #define SH_USE_NONDEFAULT_ALLOCATOR #define SH_PREFIX pagetable #define SH_ELEMENT_TYPE PagetableEntry #define SH_KEY_TYPE BlockNumber #define SH_KEY blockno -#define SH_HASH_KEY(tb, key) hash_blockno(key) +#define SH_HASH_KEY(tb, key) murmurhash32(key) #define SH_EQUAL(tb, a, b) a == b #define SH_SCOPE static inline #define SH_DEFINE |