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/include/utils/hashutils.h | |
parent | 91ad8b416cee753eaa6f520ee2d21c2d41853381 (diff) |
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/include/utils/hashutils.h')
-rw-r--r-- | src/include/utils/hashutils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/utils/hashutils.h b/src/include/utils/hashutils.h index 56b7bfc9cb9..35281689e82 100644 --- a/src/include/utils/hashutils.h +++ b/src/include/utils/hashutils.h @@ -20,4 +20,22 @@ hash_combine(uint32 a, uint32 b) return a; } + +/* + * Simple inline murmur hash implementation hashing a 32 bit ingeger, for + * 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; +} + #endif /* HASHUTILS_H */ |