Skip to main content

BlockedBloomFilter

Struct BlockedBloomFilter 

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

Cache-line-blocked Bloom filter where every lookup and insert touches at most one 64-byte cache line.

Implementations§

Source§

impl BlockedBloomFilter

Core operations for BlockedBloomFilter.

Source

pub fn with_rate(expected_items: usize, false_positive_rate: f64) -> Self

Constructs an optimally sized BlockedBloomFilter for expected_items and target false_positive_rate.

§Arguments
  • usize - Expected number of distinct elements to insert (>= 1).
  • f64 - Target false positive probability in (0.0, 1.0) (clamped to [1e-9, 0.5]).
§Returns
  • Self - Sized cache-line-blocked Bloom filter.
Source

pub fn with_blocks(block_count: usize, hash_count: u32) -> Self

Constructs a BlockedBloomFilter with explicit block_count and per-block probe count hash_count.

§Arguments
  • usize - Number of 512-bit cache-line blocks (>= 1).
  • u32 - Number of bit probes per element (1..=16).
§Returns
  • Self - Fresh empty blocked Bloom filter.
Source

pub fn insert(&mut self, item: &[u8]) -> bool

Inserts item into the filter and returns true if at least one bit changed from 0 to 1.

§Arguments
  • &[u8] - Element bytes to insert.
§Returns
  • bool - true when item was definitely not previously present.
Source

pub fn contains(&self, item: &[u8]) -> bool

Tests whether item may be present in the filter (zero false negatives).

§Arguments
  • &[u8] - Element bytes to query.
§Returns
  • bool - false if definitely absent, true if probably present.
Source

pub fn clear(&mut self)

Clears all bits to zero while keeping allocated capacity.

Source

pub fn bit_len(&self) -> usize

Returns total bit capacity (block_count * 512).

§Returns
  • usize - Total bits stored.
Source

pub fn hash_count(&self) -> u32

Returns the number of configured hash probes per element.

§Returns
  • u32 - Probe count k.
Source

pub fn count_ones(&self) -> usize

Counts total set bits across all blocks.

§Returns
  • usize - Number of 1 bits currently set.
Source

pub fn estimated_count(&self) -> f64

Estimates the number of distinct inserted elements from bit density.

§Returns
  • f64 - Estimated cardinality.
Source

pub fn union_with(&mut self, other: &Self) -> bool

Computes bitwise union (self |= other) when dimensions and hash counts match.

§Arguments
  • &Self - Other filter with identical dimensions.
§Returns
  • bool - true if merged, false if dimensions or hash counts differed.

Trait Implementations§

Source§

impl Clone for BlockedBloomFilter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for BlockedBloomFilter

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for BlockedBloomFilter

Source§

impl PartialEq for BlockedBloomFilter

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BlockedBloomFilter

Auto Trait Implementations§

§

impl Forget for BlockedBloomFilter

§

impl Freeze for BlockedBloomFilter
where *const u8 is !null: Freeze, PhantomData<BloomBlock>: Freeze,

§

impl Move for BlockedBloomFilter

§

impl RefUnwindSafe for BlockedBloomFilter

§

impl Send for BlockedBloomFilter
where RawVecInner: Send,

§

impl Sync for BlockedBloomFilter
where RawVecInner: Sync,

§

impl Unpin for BlockedBloomFilter
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for BlockedBloomFilter
where *const u8 is !null: UnsafeUnpin, PhantomData<BloomBlock>: UnsafeUnpin,

§

impl UnwindSafe for BlockedBloomFilter
where RawVecInner: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.