pub struct ShardedBloom { /* private fields */ }Expand description
分片布隆过滤器 - 减少锁竞争
将单个布隆过滤器拆分为32个分片,每个分片独立锁 不同的hash会落到不同的分片上,大幅减少竞争
Implementations§
Source§impl ShardedBloom
impl ShardedBloom
Sourcepub fn new_for_fp_rate(expected_items: usize, fp_rate: f64) -> Self
pub fn new_for_fp_rate(expected_items: usize, fp_rate: f64) -> Self
创建新的分片布隆过滤器
Sourcepub fn check_and_set(&self, hash: &[u8; 20]) -> bool
pub fn check_and_set(&self, hash: &[u8; 20]) -> bool
检查并设置元素(原子操作)
Sourcepub fn number_of_bits(&self) -> u64
pub fn number_of_bits(&self) -> u64
获取实际发现的唯一 InfoHash 数量
Auto Trait Implementations§
impl !Freeze for ShardedBloom
impl RefUnwindSafe for ShardedBloom
impl Send for ShardedBloom
impl Sync for ShardedBloom
impl Unpin for ShardedBloom
impl UnwindSafe for ShardedBloom
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more