Storm:如何将String Array从一个螺栓传递到另一个螺栓?

Rit*_*nha 4 java arraylist apache-storm

这就是我发送数据的方式

collector.emit("stream", new Values(sessionid,tables));
Run Code Online (Sandbox Code Playgroud)

在哪里sessionidtablesArrayList<String>

我不确定接收数据的螺栓是如何获得的,因为我没有找到任何东西来获取元组中的值.

这就是我接收螺栓的执行方法的样子.

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);    
}
Run Code Online (Sandbox Code Playgroud)

或者,我正在考虑合并ArrayList逗号分隔字符串中的值,并将其作为字符串传递,然后将其拆分并将其保存ArrayList在接收螺栓中.

但是,是否有任何干净的方式传递ArrayList给Storm螺栓?

Mat*_*Sax 6

你可以ArrayList毫无问题地通过.您只需要使用Tuple.getValue(int)(或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);
}
Run Code Online (Sandbox Code Playgroud)