pub struct BlockedBloomFilter { /* private fields */ }Expand description
Cache-line aligned blocked bloom filter for improved cache efficiency.
§jj.md Task 3: Blocked Bloom Filter
This implementation groups all hash probes for a key into a single cache-line sized block, reducing cache misses from k (number of hashes) to 1.
§Performance Benefits
- Cache efficiency: All probes hit the same cache line
- Reduced memory bandwidth: One cache line load vs k scattered loads
- Better TLB usage: Single page access per lookup
§Trade-offs
- Slightly higher FPR than standard bloom filter at same memory usage
- Block selection uses one hash, remaining hashes probe within block
§Reference
“Cache-Efficient Bloom Filters” (Putze et al., 2007)
Implementations§
Source§impl BlockedBloomFilter
impl BlockedBloomFilter
Sourcepub fn new(expected_items: usize, false_positive_rate: f64) -> Self
pub fn new(expected_items: usize, false_positive_rate: f64) -> Self
Create a new blocked bloom filter.
§Arguments
expected_items- Number of items expected to be insertedfalse_positive_rate- Desired false positive rate (e.g., 0.01 for 1%)
Sourcepub fn for_level(expected_items: usize, level: usize) -> Self
pub fn for_level(expected_items: usize, level: usize) -> Self
Create a blocked bloom filter with level-adaptive FPR.
Sourcepub fn contains<T: Hash>(&self, item: &T) -> bool
pub fn contains<T: Hash>(&self, item: &T) -> bool
Check if an item might be in the set.
Returns true if item might be present (could be false positive).
Returns false if item is definitely not present (100% accurate).
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Deserialize from bytes with checksum validation.
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Get size in bytes.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get memory usage in bytes.
Sourcepub fn fill_ratio(&self) -> f64
pub fn fill_ratio(&self) -> f64
Get fill ratio (fraction of bits set).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BlockedBloomFilter
impl RefUnwindSafe for BlockedBloomFilter
impl Send for BlockedBloomFilter
impl Sync for BlockedBloomFilter
impl Unpin for BlockedBloomFilter
impl UnsafeUnpin for BlockedBloomFilter
impl UnwindSafe for BlockedBloomFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more