Bloom filters for membership
medium 4 minInsert a key by setting several hash-selected bits.
Video lesson · Chapter 1 of 5
Fit membership into eight bits
Two inserted keys accidentally match a third
1:02Reel
Theory
Read or listen first. About 1 min.
What it is
A Bloom filter marks several positions for every inserted key. During a lookup, any zero at a required position proves absence for a correctly maintained insertion-only filter.
When two inserted keys look like a third
Why it exists
Two inserted keys can jointly light up every position needed by a third. A positive result therefore tells the reader when it should consult the exact store.
Words to know
- False positive
- A possible-membership response for a key that was never inserted.
How it works
Step through the idea, or press Play.
Insert A. Set positions 1 and 4.
Understand it
Worked example
Bloom filters for membership in practice
Key A sets bits 1 and 4. Key B sets 2 and 5. An absent key hashing to 1 and 5 returns a positive even though neither insertion represented that key.
Related case
Three questions for a tiny memory budget
A telemetry service needs to skip pointless disk reads, estimate traffic for a known endpoint, and count unique devices across regions. Each question allows a different error.
Estimate the union of observed identities.