Reputation: 840
This is how I am emitting the data
collector.emit("stream", new Values(sessionid,tables));
Where sessionid
and tables
are ArrayList<String>
I am not sure how the bolt which will receive the data will get it as I didn't find anything to get the value in Tuple.
This is how my execute method of receiving bolt will look.
public void execute(Tuple input, BasicOutputCollector collector) {
ArrayList<String> keyspace = input./*What to add here*/(0);
ArrayList<String> table = input./*What to add here*/(1);
}
Alternatively, I am thinking of merging the value of the ArrayList
in a comma separated string and pass it as a string and then split it and save it in ArrayList
in the receiving bolt.
But, is there any clean way to pass ArrayList
to Storm bolts?
Upvotes: 4
Views: 1209
Reputation: 62310
You can pass ArrayList
without problems. You just need to use Tuple.getValue(int)
(or Tuple.getValueByField(String)
) and cast to the correct type:
public void execute(Tuple input, BasicOutputCollector collector) {
ArrayList<String> keyspace = (ArrayList<String>)input.getValue(0);
ArrayList<String> table = (ArrayList<String>)input.getValue(1);
}
Upvotes: 6