Hacker News new | ask | show | jobs
by zintinio5 3286 days ago
If what you want is an approximate answer, take a look at

* Counting Bloom Filter https://en.wikipedia.org/wiki/Bloom_filter#Counting_filters

* Count-Min Sketch https://en.wikipedia.org/wiki/Count%E2%80%93min_sketch

Here's a library: https://datasketches.github.io/

However, you can probably fit an exact answer into memory with just a simple hashtable if you've only got 20 million objects. A single byte could be used as the state marker.

Either that, or just track 6 counts.