Struct StableBloomFilter

Source
pub struct StableBloomFilter { /* private fields */ }

Implementations§

Source§

impl StableBloomFilter

Source

pub fn new(m: usize, d: u8, fp_rate: f64) -> Self

Creates a new Stable Bloom Filter with m cells and d bits allocated per cell optimized for the target false-positive rate. Use default if you don’t want to calculate d.

Source

pub fn new_default(m: usize, fp_rate: f64) -> Self

Creates a new Stable Bloom Filter with m 1-bit cells and which is optimized for cases where there is no prior knowledge of the input data stream while maintaining an upper bound using the provided rate of false positives.

Source

pub fn new_unstable(m: usize, fp_rate: f64) -> Self

NewUnstableBloomFilter creates a new special case of Stable Bloom Filter which is a traditional Bloom filter with m bits and an optimal number of hash functions for the target false-positive rate. Unlike the stable variant, data is not evicted and a cell contains a maximum of 1 hash value.

Source

pub fn cells(&self) -> usize

Returns the number of cells in the Stable Bloom Filter.

Source

pub fn k(&self) -> usize

Returns the number of hash functions.

Source

pub fn p(&self) -> usize

Returns the number of cells decremented on every add.

Source

pub fn max(&self) -> u8

Source

pub fn stable_point(&self) -> f64

Returns the limit of the expected fraction of zeros in the Stable Bloom Filter when the number of iterations goes to infinity. When this limit is reached, the Stable Bloom Filter is considered stable.

Source

pub fn false_positive_rate(&self) -> f64

Returns the upper bound on false positives when the filter has become stable.

Source

pub fn hash_kernel(&self, data: &[u8]) -> (u32, u32)

Source

pub fn reset(&mut self) -> &Self

Restores the Stable Bloom Filter to its original state. It returns the filter to allow for chaining.

Source

pub fn decrement(&mut self)

Will decrement a random cell and (p-1) adjacent cells by 1. This is faster than generating p random numbers. Although the processes of picking the p cells are not independent, each cell has a probability of p/m for being picked at each iteration, which means the properties still hold.

Trait Implementations§

Source§

impl Filter for StableBloomFilter

Source§

fn test(&self, data: &[u8]) -> bool

Will test for membership of the data and returns true if it is a member, false if not. This is a probabilistic test, meaning there is a non-zero probability of false positives and false negatives.

Source§

fn add(&mut self, data: &[u8]) -> &Self

Will add the data to the Stable Bloom Filter. It returns the filter to allow for chaining.

Source§

fn test_and_add(&mut self, data: &[u8]) -> bool

Is equivalent to calling Test followed by Add. It returns true if the data is a member, false if not.

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V