Created
June 11, 2014 18:45
-
-
Save tdhopper/bf9bad8818c9c8fa6e5d to your computer and use it in GitHub Desktop.
This file contains 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
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