pub struct VariantBloomFilter { /* private fields */ }Expand description
A variant bloom filter, the best choice for bigger data set. In this structure, k hash functions all has it’s own slice of bitmap, whose max size is u64::MAX. Usage:
use roaring_bloom_filter::*;
let mut bf = VariantBloomFilter::new(100, 0.001_f64);
bf.add(&10);
bf.add(&'a');
bf.add(&"a string");
bf.contains(&12);Variant Bloom Filter(VBF)
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§
Source§impl VariantBloomFilter
impl VariantBloomFilter
Sourcepub fn from_scratch(
slices_length: u32,
slice_size: u64,
target_false_positive_rate: f64,
) -> VariantBloomFilter
pub fn from_scratch( slices_length: u32, slice_size: u64, target_false_positive_rate: f64, ) -> VariantBloomFilter
Create an empty variant 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 buckets length and bucket size.
Trait Implementations§
Source§impl BloomFilter for VariantBloomFilter
impl BloomFilter for VariantBloomFilter
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 VariantBloomFilter
impl RefUnwindSafe for VariantBloomFilter
impl Send for VariantBloomFilter
impl Sync for VariantBloomFilter
impl Unpin for VariantBloomFilter
impl UnwindSafe for VariantBloomFilter
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