Struct roaring_bloom_filter::BloomFilter
source · [−]pub struct BloomFilter { /* private fields */ }Expand description
A variant of bloom filter
Every hash function has it’s own slice instead of sharing the whole bitmap. This introduce the possibility of concurrency of manipulating multiply hash function at the same time.
Implementations
sourceimpl BloomFilter
impl BloomFilter
sourcepub fn from_scratch(
slices_length: u32,
slice_size: u64,
target_false_positive_rate: f64
) -> BloomFilter
pub fn from_scratch(
slices_length: u32,
slice_size: u64,
target_false_positive_rate: f64
) -> BloomFilter
Create an empty 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) -> BloomFilter
pub fn new(max_size: u64, target_false_positive: f64) -> BloomFilter
Create an empty bloom filter with max element’s size and false positive rate. The crate would calculate the best buckets length and bucket size.
sourcepub fn add<T>(&mut self, value: &T) -> bool where
T: Hash,
pub fn add<T>(&mut self, value: &T) -> bool where
T: Hash,
Add new element into the bloom filter. Return true when any key are inserted in a slice.
sourcepub fn contains<T>(&mut self, value: &T) -> bool where
T: Hash,
pub fn contains<T>(&mut self, value: &T) -> bool where
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.
sourcepub fn target_false_positive_rate(&self) -> f64
pub fn target_false_positive_rate(&self) -> f64
Get target false positive rate.
sourcepub fn current_false_positive_rate(&self) -> f64
pub fn current_false_positive_rate(&self) -> f64
Get current false positive rate.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BloomFilter
impl Send for BloomFilter
impl Sync for BloomFilter
impl Unpin for BloomFilter
impl UnwindSafe for BloomFilter
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more