Created
August 1, 2011 07:21
-
-
Save nathanmarz/1117716 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
public class SplitSentence implements IBasicBolt { | |
public void prepare(Map conf, TopologyContext context) { | |
} | |
public void execute(Tuple tuple, BasicOutputCollector collector) { | |
String sentence = tuple.getString(0); | |
for(String word: sentence.split(" ")) { | |
collector.emit(new Values(word)); | |
} | |
} | |
public void cleanup() { | |
} | |
public void declareOutputFields(OutputFieldsDeclarer declarer) { | |
declarer.declare(new Fields("word")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment