Created
December 11, 2012 22:01
-
-
Save anonymous/4262668 to your computer and use it in GitHub Desktop.
A sample barebones spout
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 SampleSpout extends BaseRichSpout { | |
private SpoutOutputCollector collector; | |
@Override | |
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { | |
this.collector = collector; | |
/* | |
* Connect to your data source here | |
* Eg. Run a query and store a reference to the cursor | |
*/ | |
} | |
@Override | |
public void nextTuple() { | |
/* | |
* Iterate through the stored cursor ref and push out | |
* one "row" into the collector as a Tuple | |
*/ | |
collector.emit("default", new Values("val1", "val2", new Object())); | |
} | |
@Override | |
public void declareOutputFields(OutputFieldsDeclarer declarer) { | |
/* | |
* Schema declaration of the stream | |
*/ | |
declarer.declareStream("default", new Fields("tweet")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment