Skip to content

Instantly share code, notes, and snippets.

@tdhopper
Created June 11, 2014 18:45
Show Gist options
  • Save tdhopper/bf9bad8818c9c8fa6e5d to your computer and use it in GitHub Desktop.
Save tdhopper/bf9bad8818c9c8fa6e5d to your computer and use it in GitHub Desktop.
from warnings import warn
from collections import Counter
from streamparse.bolt import Bolt
class WordCounter(Bolt):
def initialize(self, conf, ctx):
self.counts = Counter()
def process(self, tup):
warn("Warning!")
word = tup.values[0]
self.counts[word] += 1
self.emit([word, self.counts[word]])
self.log('%s: %d' % (word, self.counts[word]))
if __name__ == '__main__':
WordCounter().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment