Skip to content

Commit b9e7d1c

Browse files
committed
fix: fix bits calculation
1 parent e161dd3 commit b9e7d1c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/segment/filter/blocked_bloom/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ impl Builder {
103103
h1 = h1.wrapping_add(h2);
104104
h2 = h2.wrapping_mul(i);
105105

106-
let idx = h1 % (CACHE_LINE_BYTES as u64);
106+
let idx = h1 % (CACHE_LINE_BYTES as u64 * 8);
107107

108108
self.inner
109109
.enable_bit(Self::get_bit_idx(block_idx as usize, idx as usize));
110110
}
111111
}
112112

113113
pub fn get_bit_idx(block_idx: usize, idx_in_block: usize) -> usize {
114-
block_idx * CACHE_LINE_BYTES as usize + idx_in_block
114+
block_idx * CACHE_LINE_BYTES * 8 + idx_in_block
115115
}
116116

117117
/// Gets the hash of a key.

src/segment/filter/blocked_bloom/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl AMQFilter for BlockedBloomFilter {
4848
h1 = h1.wrapping_add(h2);
4949
h2 = h2.wrapping_mul(i);
5050

51-
let idx = h1 % (CACHE_LINE_BYTES as u64);
51+
let idx = h1 % (CACHE_LINE_BYTES as u64 * 8);
5252

5353
// NOTE: should be in bounds because of modulo
5454
#[allow(clippy::expect_used, clippy::cast_possible_truncation)]

0 commit comments

Comments
 (0)