Skip to content

Commit c710d24

Browse files
committed
Fix counting Bloom filter
1 parent ed55787 commit c710d24

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/counting_bloom.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class CountingBloomFilter {
7373
uint64_t *data;
7474
size_t arrayLength;
7575
HashFamily hasher;
76-
const int blockShift = 16;
76+
const int blockShift = 14;
7777
const int blockLen = 1 << blockShift;
7878

7979
void AddBlock(uint32_t *tmp, int block, int len);
@@ -100,7 +100,7 @@ Status CountingBloomFilter<ItemType, bits_per_item, branchless, HashFamily, k>::
100100
uint32_t b = (uint32_t)hash;
101101
for (int i = 0; i < k; i++) {
102102
uint index = reduce(a, this->arrayLength);
103-
data[index] += 1ULL << ((a << 2) & 63);
103+
data[index] += 1ULL << ((a << 2) & 0x3f);
104104
a += b;
105105
}
106106
return Ok;
@@ -112,7 +112,7 @@ void CountingBloomFilter<ItemType, bits_per_item, branchless, HashFamily, k>::
112112
AddBlock(uint32_t *tmp, int block, int len) {
113113
for (int i = 0; i < len; i++) {
114114
int index = tmp[(block << blockShift) + i];
115-
data[index >> 6] += 1ULL << ((index << 2) & 63);
115+
data[index >> 4] += 1ULL << ((index << 2) & 0x3f);
116116
}
117117
}
118118

@@ -132,7 +132,7 @@ Status CountingBloomFilter<ItemType, bits_per_item, branchless, HashFamily, k>::
132132
int index = reduce(a, this->arrayLength);
133133
int block = index >> blockShift;
134134
int len = tmpLen[block];
135-
tmp[(block << blockShift) + len] = (index << 6) + (a & 63);
135+
tmp[(block << blockShift) + len] = (index << 4) + (a & 0xf);
136136
tmpLen[block] = len + 1;
137137
if (len + 1 == blockLen) {
138138
AddBlock(tmp, block, len + 1);
@@ -158,7 +158,7 @@ Status CountingBloomFilter<ItemType, bits_per_item, branchless, HashFamily, k>::
158158
uint32_t b = (uint32_t)hash;
159159
for (int i = 0; i < k; i++) {
160160
uint index = reduce(a, this->arrayLength);
161-
if (((data[index] >> ((a << 2) & 63)) & 0xf) == 0) {
161+
if (((data[index] >> ((a << 2) & 0x3f)) & 0xf) == 0) {
162162
return NotFound;
163163
}
164164
a += b;
@@ -181,7 +181,7 @@ class SuccinctCountingBloomFilter {
181181
size_t overflowLength;
182182
size_t nextFreeOverflow;
183183
HashFamily hasher;
184-
const int blockShift = 13;
184+
const int blockShift = 14;
185185
const int blockLen = 1 << blockShift;
186186

187187
void Increment(size_t group, int bit);

0 commit comments

Comments
 (0)