这就是我发出数据的方式
collector.emit("stream", new Values(sessionid,tables));
Where sessionid
and tables
are ArrayList<String>
我不确定接收数据的螺栓将如何获取数据,因为我没有找到任何可以获取元组中的值的内容。
这就是我接收 Bolt 的执行方法的样子。
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);
}
或者,我正在考虑合并ArrayList
以逗号分隔的字符串并将其作为字符串传递,然后将其拆分并保存在ArrayList
在接收螺栓中。
但是,有没有什么干净的方法可以通过ArrayList
风暴螺栓?
你可以通过ArrayList
没有什么问题。你只需要使用Tuple.getValue(int)
(or Tuple.getValueByField(String)
) 并转换为正确的类型:
public void execute(Tuple input, BasicOutputCollector collector) {
ArrayList<String> keyspace = (ArrayList<String>)input.getValue(0);
ArrayList<String> table = (ArrayList<String>)input.getValue(1);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)