Struct Builder

Source
pub struct Builder<const BLOCK_SIZE_BITS: usize = 512, S = CloneBuildHasher<RandomDefaultHasher>> { /* private fields */ }
Expand description

A bloom filter builder.

This type can be used to construct an instance of BloomFilter via the builder pattern.

Implementations§

Source§

impl<const BLOCK_SIZE_BITS: usize> Builder<BLOCK_SIZE_BITS>

Source

pub fn seed(self, seed: &[u8; 16]) -> Self

Sets the seed for this builder. The later constructed BloomFilter will use this seed when hashing items.

§Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).seed(&[0u8; 16]).hashes(4);
Source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> Builder<BLOCK_SIZE_BITS, S>

Source

pub fn hasher<H: BuildHasher>(self, hasher: H) -> Builder<BLOCK_SIZE_BITS, H>

Sets the hasher for this builder. The later constructed BloomFilter will use this hasher when inserting and checking items.

§Examples
use b100m_filter::BloomFilter;
use ahash::RandomState;

let bloom = BloomFilter::builder(4).hasher(RandomState::default()).hashes(4);
Source

pub fn hashes(self, num_hashes: u64) -> BloomFilter<BLOCK_SIZE_BITS, S>

“Consumes” this builder, using the provided num_hashes to return an empty BloomFilter. For performance, the actual number of hashes performed internally will be rounded to down to a power of 2, depending on BLOCK_SIZE_BITS.

§Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).hashes(4);
Source

pub fn expected_items( self, expected_num_items: usize, ) -> BloomFilter<BLOCK_SIZE_BITS, S>

“Consumes” this builder, using the provided expected_num_items to return an empty BloomFilter. More or less than expected_num_items may be inserted into BloomFilter, but the number of hashes per item is intially calculated to minimize false positive rate for exactly expected_num_items.

§Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).expected_items(500);
Source

pub fn items<I: ExactSizeIterator<Item = impl Hash>>( self, items: I, ) -> BloomFilter<BLOCK_SIZE_BITS, S>

“Consumes” this builder and constructs a BloomFilter containing all values in items. The number of hashes per item is calculated based on items.len() to minimize false positive rate.

§Examples
use b100m_filter::BloomFilter;

let bloom = BloomFilter::builder(4).items([1, 2, 3].iter());

Trait Implementations§

Source§

impl<const BLOCK_SIZE_BITS: usize, S: Clone> Clone for Builder<BLOCK_SIZE_BITS, S>

Source§

fn clone(&self) -> Builder<BLOCK_SIZE_BITS, S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const BLOCK_SIZE_BITS: usize, S: Debug> Debug for Builder<BLOCK_SIZE_BITS, S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const BLOCK_SIZE_BITS: usize, S> Freeze for Builder<BLOCK_SIZE_BITS, S>
where S: Freeze,

§

impl<const BLOCK_SIZE_BITS: usize, S> RefUnwindSafe for Builder<BLOCK_SIZE_BITS, S>
where S: RefUnwindSafe,

§

impl<const BLOCK_SIZE_BITS: usize, S> Send for Builder<BLOCK_SIZE_BITS, S>
where S: Send,

§

impl<const BLOCK_SIZE_BITS: usize, S> Sync for Builder<BLOCK_SIZE_BITS, S>
where S: Sync,

§

impl<const BLOCK_SIZE_BITS: usize, S> Unpin for Builder<BLOCK_SIZE_BITS, S>
where S: Unpin,

§

impl<const BLOCK_SIZE_BITS: usize, S> UnwindSafe for Builder<BLOCK_SIZE_BITS, S>
where S: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

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

Source§

fn vzip(self) -> V