Skip to content

Commit

Permalink
using murmur2 for probing step
Browse files Browse the repository at this point in the history
  • Loading branch information
realead committed Oct 13, 2020
1 parent e3204b2 commit 18cf44a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion pandas/_libs/src/klib/khash.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,38 @@ typedef khint_t khiter_t;
#define __ac_set_isboth_false(flag, i) __ac_set_isempty_false(flag, i)
#define __ac_set_isdel_true(flag, i) ((void)0)


// specializations of https://github.com/aappleby/smhasher/blob/master/src/MurmurHash2.cpp
khint32_t PANDAS_INLINE murmur2_32to32(khint32_t k){
const khint32_t SEED = 0xc70f6907UL;
// 'm' and 'r' are mixing constants generated offline.
// They're not really 'magic', they just happen to work well.
const khint32_t M_32 = 0x5bd1e995;
const int R_32 = 24;

// Initialize the hash to a 'random' value
khint32_t h = SEED ^ 4;

//handle 4 bytes:
k *= M_32;
k ^= k >> R_32;
k *= M_32;

h *= M_32;
h ^= k;

// Do a few final mixes of the hash to ensure the "last few
// bytes" are well-incorporated. (Really needed here?)
h ^= h >> 13;
h *= M_32;
h ^= h >> 15;
return h;
}

#ifdef KHASH_LINEAR
#define __ac_inc(k, m) 1
#else
#define __ac_inc(k, m) (((k)>>3 ^ (k)<<3) | 1) & (m)
#define __ac_inc(k, m) (murmur2_32to32(k) | 1) & (m)
#endif

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

0 comments on commit 18cf44a

Please sign in to comment.