Skip to content

Instantly share code, notes, and snippets.

@nathanmarz
Created August 1, 2011 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanmarz/1117716 to your computer and use it in GitHub Desktop.
Save nathanmarz/1117716 to your computer and use it in GitHub Desktop.
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