Skip to content

Commit 59600e5

Browse files
committed
using quadrat_probing
1 parent c852b2e commit 59600e5

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

pandas/_libs/src/klib/khash.h

+8-15
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,6 @@ khint32_t PANDAS_INLINE murmur2_64to32(khint64_t k){
219219
}
220220

221221

222-
#ifdef KHASH_LINEAR
223-
#define __ac_inc(k, m) 1
224-
#else
225-
#define __ac_inc(k, m) (murmur2_32to32(k) | 1) & (m)
226-
#endif
227-
228222
#define __ac_fsize(m) ((m) < 32? 1 : (m)>>5)
229223

230224
#ifndef kroundup32
@@ -276,12 +270,12 @@ static const double __ac_HASH_UPPER = 0.77;
276270
SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
277271
{ \
278272
if (h->n_buckets) { \
279-
khint_t inc, k, i, last, mask; \
273+
khint_t k, i, last, mask, step = 0; \
280274
mask = h->n_buckets - 1; \
281275
k = __hash_func(key); i = k & mask; \
282-
inc = __ac_inc(k, mask); last = i; /* inc==1 for linear probing */ \
276+
last = i; /* inc==1 for linear probing */ \
283277
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
284-
i = (i + inc) & mask; \
278+
i = (i + (++step)) & mask; \
285279
if (i == last) return h->n_buckets; \
286280
} \
287281
return __ac_iseither(h->flags, i)? h->n_buckets : i; \
@@ -314,11 +308,10 @@ static const double __ac_HASH_UPPER = 0.77;
314308
if (kh_is_map) val = h->vals[j]; \
315309
__ac_set_isempty_true(h->flags, j); \
316310
while (1) { /* kick-out process; sort of like in Cuckoo hashing */ \
317-
khint_t inc, k, i; \
311+
khint_t k, i, step=0; \
318312
k = __hash_func(key); \
319313
i = k & new_mask; \
320-
inc = __ac_inc(k, new_mask); \
321-
while (!__ac_isempty(new_flags, i)) i = (i + inc) & new_mask; \
314+
while (!__ac_isempty(new_flags, i)) i = (i + (++step)) & new_mask; \
322315
__ac_set_isempty_false(new_flags, i); \
323316
if (i < h->n_buckets && __ac_iseither(h->flags, i) == 0) { /* kick out the existing element */ \
324317
{ khkey_t tmp = h->keys[i]; h->keys[i] = key; key = tmp; } \
@@ -351,14 +344,14 @@ static const double __ac_HASH_UPPER = 0.77;
351344
else kh_resize_##name(h, h->n_buckets + 1); /* expand the hash table */ \
352345
} /* TODO: to implement automatically shrinking; resize() already support shrinking */ \
353346
{ \
354-
khint_t inc, k, i, site, last, mask = h->n_buckets - 1; \
347+
khint_t k, i, site, last, mask = h->n_buckets - 1, step = 0; \
355348
x = site = h->n_buckets; k = __hash_func(key); i = k & mask; \
356349
if (__ac_isempty(h->flags, i)) x = i; /* for speed up */ \
357350
else { \
358-
inc = __ac_inc(k, mask); last = i; \
351+
last = i; \
359352
while (!__ac_isempty(h->flags, i) && (__ac_isdel(h->flags, i) || !__hash_equal(h->keys[i], key))) { \
360353
if (__ac_isdel(h->flags, i)) site = i; \
361-
i = (i + inc) & mask; \
354+
i = (i + (++step)) & mask; \
362355
if (i == last) { x = site; break; } \
363356
} \
364357
if (x == h->n_buckets) { \

0 commit comments

Comments
 (0)