Skip to main content

Crate subms_bloom_filter

Crate subms_bloom_filter 

Source
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 absent

The 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) * words

Full 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
Recipe impl for the bloom filter perf workload. Behind the harness feature.

Structs§

BloomFilter
GeometryMismatch
Returned by BloomFilter::union when the two filters were sized differently. Bit i of one filter has no relationship to bit i of the other unless m and k match, so the merge is refused rather than silently producing a filter with false negatives.