Counting Bloom Filter in C++
medium.com
medium.com
Most counting bloom filters handle this situation by using saturating arithmetic: once the count hits the maximum, it remains stuck there, never decrementing again until the filter is completely cleared (see WebKit's implementation, for example: https://github.com/WebKit/webkit/blob/master/Source/WTF/wtf/...). This maintains the Bloom Filter Guarantee™ that you can get false positives but never false negatives.
There's a paper linked in the blog post that goes into a lot of detail about minimizing false negative probability.
This counting bloom filter lets us estimate about how many times we’ve encountered a particular element in some huge set using a relatively small amount of memory.
So we’re answering two different questions with these guys:
Counting bloom filter: About how many times has a particular element shown up in this set?
(Hyper)LogLog: About how many unique elements are in this set?