Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
code fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Dec 9, 2023
1 parent 924a676 commit e4479c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/kernel/lsm/table/ss_table/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ where
}

/// 批量以restart_interval进行shared_len的获取
fn sharding_shared_len<T>(vec_kv: &Vec<KeyValue<T>>, restart_interval: usize) -> Vec<usize>
fn sharding_shared_len<T>(vec_kv: &[KeyValue<T>], restart_interval: usize) -> Vec<usize>
where
T: BlockItem,
{
Expand Down
12 changes: 8 additions & 4 deletions src/kernel/utils/bloom_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<T: ?Sized> BloomFilter<T> {
// 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);
}
}
Expand All @@ -52,7 +52,7 @@ impl<T: ?Sized> BloomFilter<T> {
{
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)
})
}
Expand Down Expand Up @@ -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<u8> {
let mut bytes = u64::encode_fixed_vec(self.len);

Expand Down Expand Up @@ -269,7 +273,7 @@ mod tests {
false_positives += 1;
}
(false, true) => {
assert!(false);
unreachable!()
} // should never happen
_ => {}
}
Expand Down

0 comments on commit e4479c1

Please sign in to comment.