Imagine a firehose: billions of search queries an hour, packets racing through a router, clicks pouring into a server. The data arrives once, far faster than you could ever write it down, and then it is gone. A natural question keeps coming back: which items show up the most? The trending searches, the chatty IP addresses, the best-selling products.
The obvious method is to keep a counter for every distinct item. But on a stream with millions of unique values, that table won't fit in memory — and on a true torrent, it never will. You get one pass and a tiny notepad.
The surprise is that you don't need a counter per item. With just a handful of counters, you can guarantee that every truly frequent item survives. The trick is knowing what to throw away.
Comments
Loading comments...