Struct fastbloom::BuilderWithFalsePositiveRate
source · pub struct BuilderWithFalsePositiveRate<const BLOCK_SIZE_BITS: usize = 512, S = DefaultHasher> { /* private fields */ }Expand description
A bloom filter builder with an immutable false positive rate.
This type can be used to construct an instance of BloomFilter via the builder pattern.
§Examples
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01);Implementations§
source§impl<const BLOCK_SIZE_BITS: usize> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS>
impl<const BLOCK_SIZE_BITS: usize> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS>
sourcepub fn seed(self, seed: &u128) -> Self
pub fn seed(self, seed: &u128) -> Self
Sets the seed for this builder. The later constructed BloomFilter
will use this seed when hashing items.
§Examples
use fastbloom::BloomFilter;
let bloom = BloomFilter::with_false_pos(0.001).seed(&1).expected_items(100);source§impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
sourcepub fn hasher<H: BuildHasher>(
self,
hasher: H
) -> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, H>
pub fn hasher<H: BuildHasher>( self, hasher: H ) -> BuilderWithFalsePositiveRate<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 fastbloom::BloomFilter;
use ahash::RandomState;
let bloom = BloomFilter::with_false_pos(0.001).hasher(RandomState::default()).expected_items(100);sourcepub fn expected_items(
self,
expected_num_items: usize
) -> BloomFilter<BLOCK_SIZE_BITS, S>
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. The number of hashes and underlying memory is optimized based on expected_num_items
to meet the desired false positive rate.
More or less than expected_num_items may be inserted into BloomFilter.
§Examples
use fastbloom::BloomFilter;
let bloom = BloomFilter::with_false_pos(0.001).expected_items(500);sourcepub fn items<I: IntoIterator<IntoIter = impl ExactSizeIterator<Item = impl Hash>>>(
self,
items: I
) -> BloomFilter<BLOCK_SIZE_BITS, S>
pub fn items<I: IntoIterator<IntoIter = impl ExactSizeIterator<Item = impl Hash>>>( self, items: I ) -> BloomFilter<BLOCK_SIZE_BITS, S>
“Consumes” this builder and constructs a BloomFilter containing
all values in items. Like BuilderWithFalsePositiveRate::expected_items, the number of hashes per item
and underlying memory is optimized based on items.len() to meet the desired false positive rate.
§Examples
use fastbloom::BloomFilter;
let bloom = BloomFilter::with_false_pos(0.001).items([1, 2, 3]);source§impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
sourcepub fn block_size_64(self) -> BuilderWithFalsePositiveRate<64, S>
pub fn block_size_64(self) -> BuilderWithFalsePositiveRate<64, S>
Set the block size of the bloom filter to 64 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.
§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_64();source§impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
sourcepub fn block_size_128(self) -> BuilderWithFalsePositiveRate<128, S>
pub fn block_size_128(self) -> BuilderWithFalsePositiveRate<128, S>
Set the block size of the bloom filter to 128 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.
§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_128();source§impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
sourcepub fn block_size_256(self) -> BuilderWithFalsePositiveRate<256, S>
pub fn block_size_256(self) -> BuilderWithFalsePositiveRate<256, S>
Set the block size of the bloom filter to 256 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.
§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_256();source§impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
sourcepub fn block_size_512(self) -> BuilderWithFalsePositiveRate<512, S>
pub fn block_size_512(self) -> BuilderWithFalsePositiveRate<512, S>
Set the block size of the bloom filter to 512 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.
§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_512();Trait Implementations§
source§impl<const BLOCK_SIZE_BITS: usize, S: Clone> Clone for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
impl<const BLOCK_SIZE_BITS: usize, S: Clone> Clone for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
source§fn clone(&self) -> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
fn clone(&self) -> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more