growable_bloom_filter

Struct GrowableBloomBuilder

Source
pub struct GrowableBloomBuilder { /* private fields */ }
Expand description

Builder API for GrowableBloom.

use growable_bloom_filter::GrowableBloomBuilder;
let mut gbloom = GrowableBloomBuilder::new()
    .estimated_insertions(100)
    .desired_error_ratio(0.05)
    .build();

Implementations§

Source§

impl GrowableBloomBuilder

Source

pub fn new() -> Self

Create a new GrowableBloomBuilder.

Builder API for GrowableBloom.

use growable_bloom_filter::GrowableBloomBuilder;
let mut gbloom = GrowableBloomBuilder::new()
    .estimated_insertions(1000)
    .desired_error_ratio(0.01)
    .growth_factor(2)
    .tightening_ratio(0.85)
    .build();
gbloom.insert("hello world");
assert!(gbloom.contains(&"hello world"));
Source

pub fn estimated_insertions(self, count: usize) -> Self

Estimated number of insertions. A power of ten accuracy is good enough.

§Panics

This will panic in debug mode if count is zero.

Source

pub fn desired_error_ratio(self, ratio: f64) -> Self

Desired error ratio (i.e. false positive rate).

Smaller error ratios will use more memory and might be a bit slower.

§Panics

This will panic if the error ratio is outside of (0, 1.0).

Source

pub fn growth_factor(self, factor: usize) -> Self

Base for the exponential growth factor.

As more items are inserted into a GrowableBloom this growth_factor number is used to exponentially grow the capacity of newly added internal bloom filters. So this number is raised to some exponent proportional to the number of bloom filters held internally.

Basically it’ll control how quickly the bloom filter grows in capacity. By default it’s set to two.

Source

pub fn tightening_ratio(self, ratio: f64) -> Self

Control the downwards adjustment on the error ratio when growing.

When GrowableBloom adds a new internal bloom filter it uses the tightening_ratio to adjust the desired_error_ratio on these new, larger internal bloom filters. This is necessary to achieve decent accuracy on the user’s desired error_ratio while using larger and larger bloom filters internally.

By default this library sets it to ~0.85, but for smaller growth factors any number around 0.8 - 0.9 should be fine.

Source

pub fn build(self) -> GrowableBloom

Consume the builder to create a GrowableBloom.

§Panics

This will panic if an invalid value is specified.

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.