Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc0fda30

Browse files
committed
Backport: Add inline murmurhash32(uint32) function.
The function already existed in tidbitmap.c but more users requiringfast hashing of 32bit ints are coming up.Author: Andres FreundDiscussion:https://postgr.es/m/20170914061207.zxotvyopetm7lrrp@alap3.anarazel.dehttps://postgr.es/m/15ae5ae2-bc74-ebef-f9d6-34b16423cc04@blackducksoftware.comOriginal-Commit:791961f
1 parent1b2a386 commitc0fda30

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

‎src/backend/nodes/tidbitmap.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include"nodes/tidbitmap.h"
4646
#include"storage/lwlock.h"
4747
#include"utils/dsa.h"
48+
#include"utils/hashutils.h"
4849

4950
/*
5051
* The maximum number of tuples per page is not large (typically 256 with
@@ -237,30 +238,13 @@ static inttbm_comparator(const void *left, const void *right);
237238
staticinttbm_shared_comparator(constvoid*left,constvoid*right,
238239
void*arg);
239240

240-
/*
241-
* Simple inline murmur hash implementation for the exact width required, for
242-
* performance.
243-
*/
244-
staticinlineuint32
245-
hash_blockno(BlockNumberb)
246-
{
247-
uint32h=b;
248-
249-
h ^=h >>16;
250-
h *=0x85ebca6b;
251-
h ^=h >>13;
252-
h *=0xc2b2ae35;
253-
h ^=h >>16;
254-
returnh;
255-
}
256-
257241
/* define hashtable mapping block numbers to PagetableEntry's */
258242
#defineSH_USE_NONDEFAULT_ALLOCATOR
259243
#defineSH_PREFIX pagetable
260244
#defineSH_ELEMENT_TYPE PagetableEntry
261245
#defineSH_KEY_TYPE BlockNumber
262246
#defineSH_KEY blockno
263-
#defineSH_HASH_KEY(tb,key)hash_blockno(key)
247+
#defineSH_HASH_KEY(tb,key)murmurhash32(key)
264248
#defineSH_EQUAL(tb,a,b) a == b
265249
#defineSH_SCOPE static inline
266250
#defineSH_DEFINE

‎src/include/utils/hashutils.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Utilities for working with hash values.
3+
*
4+
* Portions Copyright (c) 2017, PostgreSQL Global Development Group
5+
*/
6+
7+
#ifndefHASHUTILS_H
8+
#defineHASHUTILS_H
9+
10+
/*
11+
* Simple inline murmur hash implementation hashing a 32 bit ingeger, for
12+
* performance.
13+
*/
14+
staticinlineuint32
15+
murmurhash32(uint32data)
16+
{
17+
uint32h=data;
18+
19+
h ^=h >>16;
20+
h *=0x85ebca6b;
21+
h ^=h >>13;
22+
h *=0xc2b2ae35;
23+
h ^=h >>16;
24+
returnh;
25+
}
26+
27+
#endif/* HASHUTILS_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp