Skip to content

Instantly share code, notes, and snippets.

@yannick
Created May 4, 2017 12:21
Show Gist options
  • Select an option

  • Save yannick/79f87dd82cea699b1447536133cedf8c to your computer and use it in GitHub Desktop.

Select an option

Save yannick/79f87dd82cea699b1447536133cedf8c to your computer and use it in GitHub Desktop.
keep it simple stream counting
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