Bloom filters

hip-hop, educational · 2:41

Listen on 93

Lyrics

[Verse 1]
Picture this scenario, data flowing through
Million queries hitting, what you gonna do?
Traditional hash tables eating up your space
But I got a solution gonna pick up the pace
Bloom filter magic, probabilistic game
Uses bit arrays to play the membership claim
Hash functions working, maybe three or four
Mapping your data to positions galore

[Chorus]
Bloom it up, filter down, never false negative
Might get false positive but that's definitive
Space efficient, lightning quick, that's the way we roll
Hash it once, hash it twice, let the bits take control
B-L-O-O-M, memory saved today
F-I-L-T-E-R, false positives okay

[Verse 2]
Start with zeros filling every single bit
Insert an element, here's how we commit
Run it through each hash function in the set
Turn those zeros into ones, place your bet
When you query later, check each position
If any bit is zero, definite decision
Element's not there, that's a guarantee
But all ones just means possibility

[Chorus]
Bloom it up, filter down, never false negative
Might get false positive but that's definitive
Space efficient, lightning quick, that's the way we roll
Hash it once, hash it twice, let the bits take control
B-L-O-O-M, memory saved today
F-I-L-T-E-R, false positives okay

[Bridge]
Trade-off wisdom, space for accuracy
Can't delete items, that's the tragedy
More hash functions, fewer false alarms
But computation cost might cause you harm
Size your filter based on expected load
Math equations help you crack the code
Optimal ratio keeps the error low
Engineering balance, now you know

[Verse 3]
Web crawlers use them, avoiding duplicate links
Databases check existence before the system thinks
CDN networks, cache hit prediction
Distributed systems, data contradiction
Bitcoin wallets, checking transaction history
Password crackers, solving the mystery
Anywhere you need that quick membership test
Bloom filters prove they're among the best

[Chorus]
Bloom it up, filter down, never false negative
Might get false positive but that's definitive
Space efficient, lightning quick, that's the way we roll
Hash it once, hash it twice, let the bits take control
B-L-O-O-M, memory saved today
F-I-L-T-E-R, false positives okay

[Outro]
Probabilistic power in your algorithm arsenal
Bloom filters blazing, making systems optimal
Remember the trade-off, remember the gain
Space-time efficiency, that's the refrain

← Consistent hashing | Strassen's matrix multiplication →