ScalableBloomFilter

Struct ScalableBloomFilter 

Source
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

Source

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
Source

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

Source§

fn is_full(&self) -> bool

Because this is scalable bloom filter, it never gets full

Source§

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.
Source§

fn contains<T>(&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.
Source§

fn target_false_positive_rate(&self) -> f64

Get target false positive rate.
Source§

fn current_false_positive_rate(&self) -> f64

Get current false positive rate.
Source§

fn is_empty(&self) -> bool

If this bloom filter is empty.
Source§

fn size(&self) -> u64

Get the number of inserted elements in this bloom filter.
Source§

fn len(&self) -> u64

Get the number of inserted bits in all slices.
Source§

impl Display for ScalableBloomFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.