Created
May 4, 2017 12:21
-
-
Save yannick/79f87dd82cea699b1447536133cedf8c to your computer and use it in GitHub Desktop.
keep it simple stream counting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| intervall = 60 | |
| unique_ids = {} | |
| last_flush = 0 | |
| for msg in stream: | |
| unique_ids[msg["uid"]] = True #KISS | |
| if (msg["ts"] - intervall > last_flush): | |
| uniques = len( unique_ids.keys()) #ouch... but works | |
| print( "\t".join( ( msg["ts"], uniques ) )) | |
| last_flush = msg["ts"] | |
| unique_ids = {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment