File tree Expand file tree Collapse file tree 2 files changed +29
-18
lines changed Expand file tree Collapse file tree 2 files changed +29
-18
lines changed Original file line number Diff line number Diff line change 45
45
#include "nodes/tidbitmap.h"
46
46
#include "storage/lwlock.h"
47
47
#include "utils/dsa.h"
48
+ #include "utils/hashutils.h"
48
49
49
50
/*
50
51
* 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);
237
238
static int tbm_shared_comparator (const void * left , const void * right ,
238
239
void * arg );
239
240
240
- /*
241
- * Simple inline murmur hash implementation for the exact width required, for
242
- * performance.
243
- */
244
- static inline uint32
245
- hash_blockno (BlockNumber b )
246
- {
247
- uint32 h = b ;
248
-
249
- h ^= h >> 16 ;
250
- h *= 0x85ebca6b ;
251
- h ^= h >> 13 ;
252
- h *= 0xc2b2ae35 ;
253
- h ^= h >> 16 ;
254
- return h ;
255
- }
256
-
257
241
/* define hashtable mapping block numbers to PagetableEntry's */
258
242
#define SH_USE_NONDEFAULT_ALLOCATOR
259
243
#define SH_PREFIX pagetable
260
244
#define SH_ELEMENT_TYPE PagetableEntry
261
245
#define SH_KEY_TYPE BlockNumber
262
246
#define SH_KEY blockno
263
- #define SH_HASH_KEY (tb , key ) hash_blockno (key)
247
+ #define SH_HASH_KEY (tb , key ) murmurhash32 (key)
264
248
#define SH_EQUAL (tb , a , b ) a == b
265
249
#define SH_SCOPE static inline
266
250
#define SH_DEFINE
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Utilities for working with hash values.
3
+ *
4
+ * Portions Copyright (c) 2017, PostgreSQL Global Development Group
5
+ */
6
+
7
+ #ifndef HASHUTILS_H
8
+ #define HASHUTILS_H
9
+
10
+ /*
11
+ * Simple inline murmur hash implementation hashing a 32 bit ingeger, for
12
+ * performance.
13
+ */
14
+ static inline uint32
15
+ murmurhash32 (uint32 data )
16
+ {
17
+ uint32 h = data ;
18
+
19
+ h ^= h >> 16 ;
20
+ h *= 0x85ebca6b ;
21
+ h ^= h >> 13 ;
22
+ h *= 0xc2b2ae35 ;
23
+ h ^= h >> 16 ;
24
+ return h ;
25
+ }
26
+
27
+ #endif /* HASHUTILS_H */
You can’t perform that action at this time.
0 commit comments