TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Bloom filters explained in a single image

98 pointsby polyrandabout 4 years ago

17 comments

eisabout 4 years ago
Bloom filters explained in a single HN comment:<p>They are an efficient implementation of a Set that contains hashes of the elements.<p>bloomfilter.add(&quot;foo&quot;) will internally add hash(&quot;foo&quot;) to the Set<p>bloomfilter.has(&quot;foo&quot;) checks if the Set contains hash(&quot;foo&quot;)<p>False positives arise due to different elements hashing to the same hash. If &quot;foo&quot; and &quot;bar&quot; hash to the same value, bloomfilter.has(&quot;bar&quot;) would return true.<p>No false negatives are possible.<p>They are used when an actual check for an element in a datastructure is quite costly and the hitrate for not-in-the-datastructure is non-trivial and can therefor be skipped if the bloomfilter gives a negative.
评论 #26773475 未加载
评论 #26777239 未加载
评论 #26777154 未加载
评论 #26773356 未加载
anon_tor_12345about 4 years ago
&quot;bloom filters explain in a single image&quot; where 90% of the image is text. so just bloom filters explained in 2-3 paragraphs?<p>fig 3 here<p><a href="https:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;pii&#x2F;S1389128613003083#f0015" rel="nofollow">https:&#x2F;&#x2F;www.sciencedirect.com&#x2F;science&#x2F;article&#x2F;pii&#x2F;S138912861...</a><p>is a much better &quot;single image&quot; explanation (insofar as any single image could be sufficiently explanatory) of bloom filters.
评论 #26772602 未加载
bradleyjgabout 4 years ago
What is it about bloom filters that makes people want to explain them to others? I think I’ve seen more blog posts about them than any other cs topic, with the possible exception of monads.
评论 #26772835 未加载
评论 #26773995 未加载
评论 #26772916 未加载
评论 #26772767 未加载
评论 #26772892 未加载
polyrandabout 4 years ago
Hi, author here!<p>I have created that site to summarize concepts I find interesting, while providing examples or use cases.<p>My biggest inspiration comes from Julia Evans and her zines[0]. I started drawing the things I was learning about, and I thought the format could be useful for other people.<p>Right now I&#x27;m diving into a mix of hashing functions&#x2F;cryptography, data structures and databases. I usually spend a few days learning about a concept, and then I try to summarize it in a constrained drawing frame (I use Excalidraw[1] to do it and some logos from drwn.io[2]). I&#x27;m happy to accept suggestions about interesting topics to explore, draw and summarize.<p>[0] <a href="https:&#x2F;&#x2F;wizardzines.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;wizardzines.com&#x2F;</a> [1] <a href="https:&#x2F;&#x2F;excalidraw.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;excalidraw.com&#x2F;</a> [2] <a href="https:&#x2F;&#x2F;drwn.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;drwn.io&#x2F;</a>
评论 #26772937 未加载
reivalcabout 4 years ago
thanks for the post, it inspired this naive code:<p><pre><code> class BloomFilter: def __init__(self, size): self.f = [0] * size def contains(self, s): h1, h2, h3 = self.hashes(s) if self.f[h1] * self.f[h2] * self.f[h3] == 1: return &#x27;Value might be in the set.&#x27; else: return &#x27;Value is definitely not in the set.&#x27; def hashes(self, s): h1 = hash(s) % len(self.f) h2 = hash(s + &#x27;salt&#x27;) % len(self.f) h3 = hash(s + &#x27;more salt&#x27;) % len(self.f) return h1, h2, h3 def insert(self, s): h1, h2, h3 = self.hashes(s) self.f[h1] = self.f[h2] = self.f[h3] = 1 bf = BloomFilter(64) bf.insert(&#x27;bill&#x27;) print(f&quot;{bf.contains(&#x27;bill&#x27;) = }&quot;) print(f&quot;{bf.contains(&#x27;bob&#x27;) = }&quot;) Out: bf.contains(&#x27;bill&#x27;) = &#x27;Value might be in the set.&#x27; bf.contains(&#x27;bob&#x27;) = &#x27;Value is definitely not in the set.&#x27;</code></pre>
评论 #26773297 未加载
kowloabout 4 years ago
This is great but the title is a little misleading for me. Perhaps &quot;bloom filters explained in a poster&quot;...<p>This contains multiple paragraphs and figures. You couldn&#x27;t screenshot a wikipedia page and claim the same!
superasnabout 4 years ago
I didn&#x27;t understand a thing from this image but I was definitely intrigued and so I found a video on Youtube(1) that explains it quite simply (like for dummies) and now I fully understand it!<p>You can watch it at 2.5x speed without missing out on anything:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=kfFacplFY4Y" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=kfFacplFY4Y</a>
评论 #26772819 未加载
tyingqabout 4 years ago
For a really high level that includes how people practically use one with storage, I like this simple image:<p><a href="https:&#x2F;&#x2F;academy.bit2me.com&#x2F;wp-content&#x2F;uploads&#x2F;2020&#x2F;06&#x2F;como-funciona-un-filtro-bloom-1024x576.webp" rel="nofollow">https:&#x2F;&#x2F;academy.bit2me.com&#x2F;wp-content&#x2F;uploads&#x2F;2020&#x2F;06&#x2F;como-f...</a>
notacowardabout 4 years ago
Fun fact: the original pre-computer punch cards used for the census etc. were quite like Bloom filters with degenerate hash functions. Some of the same principles of key number&#x2F;width, density, and pollution even apply. I&#x27;ve often thought that would be a good place to start, if I ever had to explain Bloom filters to a layman or beginner.
joshlemerabout 4 years ago
I&#x27;ve just thought about how you could also have a &quot;Bloom Map&quot;, basically as a HashSet is to Bloom Filter, a HashMap would be to a Bloom Map. It would be able to answer lookups with either &quot;Definitely not present&quot; or &quot;Might map to value XYZ&quot;.
评论 #26776160 未加载
vangelisabout 4 years ago
My first thought about Bloom filters is always what does this have to do with shaders.
bryzaguyabout 4 years ago
Can someone help me understand the value of hashing? If you’re using modulus to bucket, why not just use the string length or something? Is it because the values will distribute across buckets more uniformly?
评论 #26774184 未加载
throw14082020about 4 years ago
&gt; Bloom filters test if an element is part of a set, without needing to store the entire set<p><a href="https:&#x2F;&#x2F;python.land&#x2F;bloom-filter" rel="nofollow">https:&#x2F;&#x2F;python.land&#x2F;bloom-filter</a><p>There.
tonke90about 4 years ago
I&#x27;ve used Bloom filters and found them to be memory latency bound, as queries can not be cached (big data structure, random access). Any recommendations on how to speed up queries?
评论 #26773448 未加载
评论 #26773237 未加载
gbritsabout 4 years ago
To be complete something along the lines of: ‘if the answer is “maybe yes” a more computationally expensive is used to definitely decide yes or no’ should me added imo
FatalLogicabout 4 years ago
Can this be explained, more simply, by saying that many different strings will be represented by a single hash?
评论 #26773578 未加载
评论 #26772849 未加载
sullyj3about 4 years ago
What&#x27;s the intuition behind the name?
评论 #26776471 未加载