mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 15:51:24 +02:00
Add hash_combine64.
Extracted from a larger patch by Amul Sul, with some comment additions by me. Discussion: http://postgr.es/m/20171024113004.hn5qajypin4dy5sw@alap3.anarazel.de
This commit is contained in:
parent
60651e4cdd
commit
b7f3eb3140
@ -8,8 +8,8 @@
|
|||||||
#define HASHUTILS_H
|
#define HASHUTILS_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Combine two hash values, resulting in another hash value, with decent bit
|
* Combine two 32-bit hash values, resulting in another hash value, with
|
||||||
* mixing.
|
* decent bit mixing.
|
||||||
*
|
*
|
||||||
* Similar to boost's hash_combine().
|
* Similar to boost's hash_combine().
|
||||||
*/
|
*/
|
||||||
@ -20,6 +20,18 @@ hash_combine(uint32 a, uint32 b)
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Combine two 64-bit hash values, resulting in another hash value, using the
|
||||||
|
* same kind of technique as hash_combine(). Testing shows that this also
|
||||||
|
* produces good bit mixing.
|
||||||
|
*/
|
||||||
|
static inline uint64
|
||||||
|
hash_combine64(uint64 a, uint64 b)
|
||||||
|
{
|
||||||
|
/* 0x49a0f4dd15e5a8e3 is 64bit random data */
|
||||||
|
a ^= b + 0x49a0f4dd15e5a8e3 + (a << 54) + (a >> 7);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Simple inline murmur hash implementation hashing a 32 bit integer, for
|
* Simple inline murmur hash implementation hashing a 32 bit integer, for
|
||||||
|
Loading…
Reference in New Issue
Block a user