pub struct ScalableBloomFilter { /* private fields */ }Expand description
A scalable bloom filter implementation, based on VariantBloomFilter.
use roaring_bloom_filter::*;
let mut bf = ScalableBloomFilter::new(100, 0.001_f64);
bf.add(&10);
bf.add(&'a');
bf.add(&"a string");
bf.contains(&12);Scalable Bloom Filter(SBF)
SBF is based on variant bloom filter, consists of one or more filter. When the first filter is full, a brand new filter with more k and smaller target false positive rate would be added, extending capacity of SBF while promising target false positive rate.
Implementations§
Source§impl ScalableBloomFilter
impl ScalableBloomFilter
Sourcepub fn from_scratch(
first_slices_length: u32,
slice_size: u64,
s: u8,
r: f64,
target_false_positive_rate: f64,
) -> ScalableBloomFilter
pub fn from_scratch( first_slices_length: u32, slice_size: u64, s: u8, r: f64, target_false_positive_rate: f64, ) -> ScalableBloomFilter
Create an empty scalable 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
- s = 2 or 4
- 0.8 <= r <= 0.9
- 0 < f < 1
Sourcepub fn new(first_max_size: u64, target_false_positive: f64) -> impl BloomFilter
pub fn new(first_max_size: u64, target_false_positive: f64) -> impl BloomFilter
Create an empty bloom filter with max element’s size for the first filter and false positive rate. The crate would calculate the best buckets length and bucket size, and make s = 4, r = 0.9.
Trait Implementations§
Source§impl BloomFilter for ScalableBloomFilter
impl BloomFilter for ScalableBloomFilter
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 ScalableBloomFilter
impl RefUnwindSafe for ScalableBloomFilter
impl Send for ScalableBloomFilter
impl Sync for ScalableBloomFilter
impl Unpin for ScalableBloomFilter
impl UnwindSafe for ScalableBloomFilter
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