diff options
author | Cody Hiar <cody@hiar.ca> | 2021-10-25 14:34:37 -0600 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-10-25 14:34:37 -0600 |
commit | e3d2ffca585660f0c088ab8323bfe78a86ba75e3 (patch) | |
tree | 1f542c4d1c032cdc85149ccfd28cafc402ddb3d0 /wordcount/src/bolts/wordcount.py | |
parent | 08cf73a70e3ce2dbc85e8b389f15090c148ec003 (diff) |
Save working version of deploying jars
Diffstat (limited to 'wordcount/src/bolts/wordcount.py')
-rw-r--r-- | wordcount/src/bolts/wordcount.py | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/wordcount/src/bolts/wordcount.py b/wordcount/src/bolts/wordcount.py deleted file mode 100644 index 85fbfb7..0000000 --- a/wordcount/src/bolts/wordcount.py +++ /dev/null @@ -1,26 +0,0 @@ -import os -from collections import Counter - -from streamparse import Bolt - - -class WordCountBolt(Bolt): - outputs = ["word", "count"] - - def initialize(self, conf, ctx): - self.counter = Counter() - self.pid = os.getpid() - self.total = 0 - - def _increment(self, word, inc_by): - self.counter[word] += inc_by - self.total += inc_by - - def process(self, tup): - word = tup.values[0] - self._increment(word, 10 if word == "dog" else 1) - if self.total % 1000 == 0: - self.logger.info( - f"counted [{self.total:,}] words [pid={self.pid}]" - ) - self.emit([word, self.counter[word]]) |