aboutsummaryrefslogtreecommitdiff
path: root/wordcount/multilang/resources/splitbolt.py
blob: b46a901f3f393d58afb61f02e0b0e7fe8672232b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import storm

class SplitBolt(storm.BasicBolt):
    # There's nothing to initialize here,
    # since this is just a split and emit
    # Initialize this instance
    def initialize(self, conf, context):
        self._conf = conf
        self._context = context
        storm.logInfo("Split bolt instance starting...")

    def process(self, tup):
        # Split the inbound sentence at spaces
        words = tup.values[0].split()
        # Loop over words and emit
        for word in words:
            storm.logInfo("Emitting %s" % word)
            storm.emit([word])

# Start the bolt when it's invoked
SplitBolt().run()