Expand description
Minimal bloom filter - standalone, reusable, zero-dependency.
Standard double-hashed bloom filter: FNV-1a 64-bit produces two 32-bit subhashes for the double-hashing trick. Sizing defaults to ~10 bits per key and k=7, which gives ~1% false-positive rate. Suitable as a building block for other cookbook samples (LSM tree SSTables, in particular).
use subms_bloom_filter::BloomFilter;
let mut bf = BloomFilter::new(10_000);
bf.add("alice");
assert!(bf.might_contain("alice")); // stored keys always report present
assert!(!bf.might_contain("bob")); // absent keys usually report absentThe on-disk layout is fixed and language-agnostic:
bit_count: u32 (big-endian)
k: u32 (big-endian)
words: u32 (big-endian) - number of u64 words
bits: (u64 big-endian) * wordsFull writeup, design notes and measured benchmarks: https://www.submillisecond.com/cookbook/recipes/subms-bloom-filter
Re-exports§
pub use features::counting::CountingBloomFilter;pub use features::partitioned::PartitionedBloomFilter;pub use features::scalable::ScalableBloomFilter;
Modules§
- features
- Opt-in feature catalog. Each submodule is gated by its own Cargo feature flag and adds a specific capability to the base bloom filter without bloating the core build.
- recipe
Recipeimpl for the bloom filter perf workload. Behind theharnessfeature.
Structs§
- Bloom
Filter - Geometry
Mismatch - Returned by
BloomFilter::unionwhen the two filters were sized differently. Bitiof one filter has no relationship to bitiof the other unlessmandkmatch, so the merge is refused rather than silently producing a filter with false negatives.