broomfilter 0.1.0

A bloom filter that sweeps away your certainty. Probably.
Documentation

๐Ÿงน broomfilter ๐Ÿงน

Sweeping away your certainty, one hash at a time.

A bloom filter implementation in Rust. Named broomfilter because it sweeps through your data and tells you "yeah, probably" with the confidence of someone who definitely didn't study for the exam.


๐Ÿค” What is this?

A bloom filter is a probabilistic data structure that can tell you:

  • โŒ "Definitely not in the set" โ€” 100% accurate, take it to the bank
  • ๐Ÿคท "Probably in the set" โ€” maybe, who knows, trust issues

Think of it as that friend who says "I'm pretty sure I locked the door." You can trust them when they say they didn't, but when they say they did... you might want to go check.

๐Ÿงน How the broom sweeps

    item โ”€โ”€โ†’ [ hash hash hash ] โ”€โ”€โ†’ flip bits in the array
                  ๐Ÿงน๐Ÿ’จ

    query โ”€โ”€โ†’ [ hash hash hash ] โ”€โ”€โ†’ check bits
                                      โ”œโ”€โ”€ all set?   โ†’ "probably yes" ๐Ÿคท
                                      โ””โ”€โ”€ any unset? โ†’ "definitely no" โŒ

๐Ÿ’ก Why does this exist?

Because I wanted to learn what a bloom filter actually is instead of just nodding along when someone mentions one in a meeting. Turns out it's a big array of bits and some hashing. Who knew? (Everyone. Everyone knew.) ๐Ÿงน


๐Ÿš€ Usage

use broomfilter::Filter;

// Create a filter with 2^14 bits, optimized for 10,000 items
let mut filter = Filter::new(14, 10_000).unwrap();

// Insert some things ๐Ÿงน
filter.insert("hello");
filter.insert("world");

// Check for things
assert!(filter.contains("hello"));    // true  โ€” probably  ๐Ÿคท
assert!(!filter.contains("goodbye")); // false โ€” definitely โŒ

๐Ÿ—๏ธ Status

โš ๏ธ Work in progress โ€” handle with care (or don't, I'm a README not a cop)

It works, it has benchmarks, it probably won't eat your data. But then again, the whole point of a bloom filter is that you can never be 100% sure about anything.

Feature Status
Insert items โœ… Swept in
Check membership โœ… Probably
False positives โœ… It's a feature
False negatives ๐Ÿšซ Impossible (finally, some certainty)
Delete items ๐Ÿงน Nope, the broom only sweeps one way

๐Ÿ“œ License

MIT โ€” do whatever you want with it, just don't blame me when contains() lies to you. That's a feature, not a bug. ๐Ÿงน