From e4479c14708418c25689d71c98154acf25c2d97d Mon Sep 17 00:00:00 2001 From: Kould <2435992353@qq.com> Date: Sat, 9 Dec 2023 16:38:59 +0800 Subject: [PATCH] code fmt --- src/kernel/lsm/table/ss_table/block.rs | 2 +- src/kernel/utils/bloom_filter.rs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/kernel/lsm/table/ss_table/block.rs b/src/kernel/lsm/table/ss_table/block.rs index fcb97be..10af548 100644 --- a/src/kernel/lsm/table/ss_table/block.rs +++ b/src/kernel/lsm/table/ss_table/block.rs @@ -642,7 +642,7 @@ where } /// 批量以restart_interval进行shared_len的获取 -fn sharding_shared_len(vec_kv: &Vec>, restart_interval: usize) -> Vec +fn sharding_shared_len(vec_kv: &[KeyValue], restart_interval: usize) -> Vec where T: BlockItem, { diff --git a/src/kernel/utils/bloom_filter.rs b/src/kernel/utils/bloom_filter.rs index 432b3e0..eb0046b 100644 --- a/src/kernel/utils/bloom_filter.rs +++ b/src/kernel/utils/bloom_filter.rs @@ -41,7 +41,7 @@ impl BloomFilter { // g_i(x) = h1(x) + i * h2(x) let hashes = self.make_hash(elem); for fn_i in 0..self.hash_fn_count { - let index = self.get_index(hashes, fn_i as u64); + let index = self.get_index(hashes, fn_i); self.bits.set_bit(index, true); } } @@ -52,7 +52,7 @@ impl BloomFilter { { let hashes = self.make_hash(elem); (0..self.hash_fn_count).all(|fn_i| { - let index = self.get_index(hashes, fn_i as u64); + let index = self.get_index(hashes, fn_i); self.bits.get_bit(index) }) } @@ -135,13 +135,17 @@ impl BitVector { } pub fn get_bit(&self, index: usize) -> bool { - (self.bit_groups[index / 8] >> index % 8) & 1 != 0 + self.bit_groups[index / 8] >> index % 8 & 1 != 0 } pub fn len(&self) -> usize { self.len as usize } + pub fn is_empty(&self) -> bool { + self.len == 0 + } + pub fn to_raw(&self) -> Vec { let mut bytes = u64::encode_fixed_vec(self.len); @@ -269,7 +273,7 @@ mod tests { false_positives += 1; } (false, true) => { - assert!(false); + unreachable!() } // should never happen _ => {} }