/Users/deen/code/yugabyte-db/src/postgres/src/include/utils/hashutils.h
Line | Count | Source |
1 | | /* |
2 | | * Utilities for working with hash values. |
3 | | * |
4 | | * Portions Copyright (c) 2017-2018, PostgreSQL Global Development Group |
5 | | */ |
6 | | |
7 | | #ifndef HASHUTILS_H |
8 | | #define HASHUTILS_H |
9 | | |
10 | | /* |
11 | | * Combine two 32-bit hash values, resulting in another hash value, with |
12 | | * decent bit mixing. |
13 | | * |
14 | | * Similar to boost's hash_combine(). |
15 | | */ |
16 | | static inline uint32 |
17 | | hash_combine(uint32 a, uint32 b) |
18 | 34.7k | { |
19 | 34.7k | a ^= b + 0x9e3779b9 + (a << 6) + (a >> 2); |
20 | 34.7k | return a; |
21 | 34.7k | } Line | Count | Source | 18 | 34.7k | { | 19 | 34.7k | a ^= b + 0x9e3779b9 + (a << 6) + (a >> 2); | 20 | 34.7k | return a; | 21 | 34.7k | } |
Unexecuted instantiation: execGrouping.c:hash_combine Unexecuted instantiation: tidbitmap.c:hash_combine Unexecuted instantiation: partbounds.c:hash_combine Unexecuted instantiation: catcache.c:hash_combine |
22 | | |
23 | | /* |
24 | | * Combine two 64-bit hash values, resulting in another hash value, using the |
25 | | * same kind of technique as hash_combine(). Testing shows that this also |
26 | | * produces good bit mixing. |
27 | | */ |
28 | | static inline uint64 |
29 | | hash_combine64(uint64 a, uint64 b) |
30 | 100k | { |
31 | | /* 0x49a0f4dd15e5a8e3 is 64bit random data */ |
32 | 100k | a ^= b + UINT64CONST(0x49a0f4dd15e5a8e3) + (a << 54) + (a >> 7); |
33 | 100k | return a; |
34 | 100k | } Unexecuted instantiation: tupdesc.c:hash_combine64 Unexecuted instantiation: execGrouping.c:hash_combine64 Unexecuted instantiation: tidbitmap.c:hash_combine64 partbounds.c:hash_combine64 Line | Count | Source | 30 | 100k | { | 31 | | /* 0x49a0f4dd15e5a8e3 is 64bit random data */ | 32 | 100k | a ^= b + UINT64CONST(0x49a0f4dd15e5a8e3) + (a << 54) + (a >> 7); | 33 | 100k | return a; | 34 | 100k | } |
Unexecuted instantiation: catcache.c:hash_combine64 |
35 | | |
36 | | /* |
37 | | * Simple inline murmur hash implementation hashing a 32 bit integer, for |
38 | | * performance. |
39 | | */ |
40 | | static inline uint32 |
41 | | murmurhash32(uint32 data) |
42 | 23.6M | { |
43 | 23.6M | uint32 h = data; |
44 | | |
45 | 23.6M | h ^= h >> 16; |
46 | 23.6M | h *= 0x85ebca6b; |
47 | 23.6M | h ^= h >> 13; |
48 | 23.6M | h *= 0xc2b2ae35; |
49 | 23.6M | h ^= h >> 16; |
50 | 23.6M | return h; |
51 | 23.6M | } Unexecuted instantiation: tupdesc.c:murmurhash32 execGrouping.c:murmurhash32 Line | Count | Source | 42 | 307k | { | 43 | 307k | uint32 h = data; | 44 | | | 45 | 307k | h ^= h >> 16; | 46 | 307k | h *= 0x85ebca6b; | 47 | 307k | h ^= h >> 13; | 48 | 307k | h *= 0xc2b2ae35; | 49 | 307k | h ^= h >> 16; | 50 | 307k | return h; | 51 | 307k | } |
Line | Count | Source | 42 | 21.3k | { | 43 | 21.3k | uint32 h = data; | 44 | | | 45 | 21.3k | h ^= h >> 16; | 46 | 21.3k | h *= 0x85ebca6b; | 47 | 21.3k | h ^= h >> 13; | 48 | 21.3k | h *= 0xc2b2ae35; | 49 | 21.3k | h ^= h >> 16; | 50 | 21.3k | return h; | 51 | 21.3k | } |
Unexecuted instantiation: partbounds.c:murmurhash32 Line | Count | Source | 42 | 23.3M | { | 43 | 23.3M | uint32 h = data; | 44 | | | 45 | 23.3M | h ^= h >> 16; | 46 | 23.3M | h *= 0x85ebca6b; | 47 | 23.3M | h ^= h >> 13; | 48 | 23.3M | h *= 0xc2b2ae35; | 49 | 23.3M | h ^= h >> 16; | 50 | 23.3M | return h; | 51 | 23.3M | } |
|
52 | | |
53 | | #endif /* HASHUTILS_H */ |