33
44#include < algorithm>
55#include < assert.h>
6+ #include < sstream>
67
78#include " hashutil.h"
89
@@ -112,6 +113,14 @@ template <typename ItemType, size_t bits_per_item, bool branchless,
112113 typename HashFamily, int k>
113114Status BloomFilter<ItemType, bits_per_item, branchless, HashFamily, k>::AddAll(
114115 const ItemType* keys, const size_t start, const size_t end) {
116+ // we have that AddAll assumes that arrayLength << 6 is a
117+ // 32-bit integer
118+ if (arrayLength > 0x3ffffff ) {
119+ for (size_t i = start; i < end; i++) {
120+ Add (keys[i]);
121+ }
122+ return Ok;
123+ }
115124 int blocks = 1 + arrayLength / blockLen;
116125 uint32_t *tmp = new uint32_t [blocks * blockLen];
117126 int *tmpLen = new int [blocks]();
@@ -243,12 +252,6 @@ SimpleBlockFilter<blocksize, k, HashFamily>::Add(const uint64_t key) noexcept {
243252 const auto hash = hasher_ (key);
244253 const uint32_t idx = reduce (hash, arrayLength);
245254 uint64_t *bucket = data + idx;
246- // uint32_t a = (uint32_t)(hash ^ (hash >> 32));
247-
248- // *bucket++ |= (uint64_t) ((1L << (a & 63)) | (1L << ((a >> 6) & 63)));
249- // *bucket |= (uint64_t) ((1L << ((a >> 12) & 63)) | (1L << ((a >> 18) & 63)));
250-
251- // *bucket++ |= (uint64_t) (a & (a >> 1));
252255 uint64_t m1 = 1L << hash;
253256 uint64_t m2 = 1L << (hash >> 8 );
254257 uint64_t m = m1 | m2;
@@ -262,21 +265,10 @@ SimpleBlockFilter<blocksize, k, HashFamily>::Find(const uint64_t key) const
262265 const auto hash = hasher_ (key);
263266 const uint32_t idx = reduce (hash, arrayLength);
264267 uint64_t *bucket = data + idx;
265- // uint32_t a = (uint32_t)(hash ^ (hash >> 32));
266- // uint64_t m1 = (uint64_t) ((1L << (a & 63)) | (1L << ((a >> 6) & 63)));
267- // uint64_t m2 = (uint64_t) ((1L << ((a >> 12) & 63)) | (1L << ((a >> 18) & 63)));
268268 uint64_t m1 = 1L << hash;
269269 uint64_t m2 = 1L << (hash >> 8 );
270270 uint64_t m = m1 | m2;
271271 return !((m & *bucket) - m);
272-
273- /*
274- uint64_t x = *bucket++;
275- // a += b;
276- // x = *bucket++;
277- // y &= (x >> (a & 63)) & (x >> ((a >> 8) & 63));
278- return y & 1;
279- */
280272}
281273
282274} // namespace bloomfilter
0 commit comments