pub struct StableBloomFilter { /* private fields */ }Expand description
Stable bloom filter, the best choice for small data set. In this structure, k hash functions share a global bitmap, whose max size is u64::MAX. Usage:
use roaring_bloom_filter::*;
let mut bf = StableBloomFilter::new(100, 0.001_f64);
bf.add(&10);
bf.add(&'a');
bf.add(&"a string");
bf.contains(&12);Stable Bloom Filter(SBF)
All hash function share the whole bitmap. Best choice for relatively small dataset.
Implementations§
Source§impl StableBloomFilter
impl StableBloomFilter
Sourcepub fn from_scratch(
hash_num: u32,
bitmap_size: u64,
target_false_positive_rate: f64,
) -> StableBloomFilter
pub fn from_scratch( hash_num: u32, bitmap_size: u64, target_false_positive_rate: f64, ) -> StableBloomFilter
Create an empty stable bloom filter from scratch.
Generally, user should not use this initializer directly. Promise the limitation on yourself:
- 0 < k <= u32::MAX
- 0 < m <= u32::MAX
- 0 < f < 1
Sourcepub fn new(max_size: u64, target_false_positive: f64) -> impl BloomFilter
pub fn new(max_size: u64, target_false_positive: f64) -> impl BloomFilter
Create an empty bloom filter with max element’s size and false positive rate. The crate would calculate the best hash number and bitmap size.
Trait Implementations§
Source§impl BloomFilter for StableBloomFilter
impl BloomFilter for StableBloomFilter
Source§fn add<T>(&mut self, value: &T) -> boolwhere
T: Hash,
fn add<T>(&mut self, value: &T) -> boolwhere
T: Hash,
Add new element into the bloom filter.
Return true when any key are inserted in a slice.
Source§fn contains<T>(&self, value: &T) -> boolwhere
T: Hash,
fn contains<T>(&self, value: &T) -> boolwhere
T: Hash,
Check if the bloom filter contains the specific key.
Return true when all key are present in all slices, which may contains false positive situation.
Source§fn target_false_positive_rate(&self) -> f64
fn target_false_positive_rate(&self) -> f64
Get target false positive rate.
Source§fn current_false_positive_rate(&self) -> f64
fn current_false_positive_rate(&self) -> f64
Get current false positive rate.
Auto Trait Implementations§
impl Freeze for StableBloomFilter
impl RefUnwindSafe for StableBloomFilter
impl Send for StableBloomFilter
impl Sync for StableBloomFilter
impl Unpin for StableBloomFilter
impl UnwindSafe for StableBloomFilter
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