Skip to content

Commit 18cf44a

Browse files
committed
using murmur2 for probing step
1 parent e3204b2 commit 18cf44a

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

pandas/_libs/src/klib/khash.h

+29-1
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,38 @@ typedef khint_t khiter_t;
143143
#define __ac_set_isboth_false(flag, i) __ac_set_isempty_false(flag, i)
144144
#define __ac_set_isdel_true(flag, i) ((void)0)
145145

146+
147+
// specializations of https://github.com/aappleby/smhasher/blob/master/src/MurmurHash2.cpp
148+
khint32_t PANDAS_INLINE murmur2_32to32(khint32_t k){
149+
const khint32_t SEED = 0xc70f6907UL;
150+
// 'm' and 'r' are mixing constants generated offline.
151+
// They're not really 'magic', they just happen to work well.
152+
const khint32_t M_32 = 0x5bd1e995;
153+
const int R_32 = 24;
154+
155+
// Initialize the hash to a 'random' value
156+
khint32_t h = SEED ^ 4;
157+
158+
//handle 4 bytes:
159+
k *= M_32;
160+
k ^= k >> R_32;
161+
k *= M_32;
162+
163+
h *= M_32;
164+
h ^= k;
165+
166+
// Do a few final mixes of the hash to ensure the "last few
167+
// bytes" are well-incorporated. (Really needed here?)
168+
h ^= h >> 13;
169+
h *= M_32;
170+
h ^= h >> 15;
171+
return h;
172+
}
173+
146174
#ifdef KHASH_LINEAR
147175
#define __ac_inc(k, m) 1
148176
#else
149-
#define __ac_inc(k, m) (((k)>>3 ^ (k)<<3) | 1) & (m)
177+
#define __ac_inc(k, m) (murmur2_32to32(k) | 1) & (m)
150178
#endif
151179

152180
#define __ac_fsize(m) ((m) < 32? 1 : (m)>>5)

0 commit comments

Comments
 (0)