Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache storm Storm tuple.getIntegerByField未按预期工作_Apache Storm - Fatal编程技术网

Apache storm Storm tuple.getIntegerByField未按预期工作

Apache storm Storm tuple.getIntegerByField未按预期工作,apache-storm,Apache Storm,我有一个包含以下数据的元组 第一列是“受影响的账户” 当我跑的时候 tuple.getIntegerByField("affectedAccount"); this.affectedAccount = Integer.parseInt(tuple.getStringByField("affectedAccount")); 它抛出ClassCastException 当我跑的时候 tuple.getIntegerByField("affectedAccount"); this.affec

我有一个包含以下数据的元组 第一列是“受影响的账户”

当我跑的时候

tuple.getIntegerByField("affectedAccount");
 this.affectedAccount = Integer.parseInt(tuple.getStringByField("affectedAccount"));
它抛出
ClassCastException
当我跑的时候

tuple.getIntegerByField("affectedAccount");
 this.affectedAccount = Integer.parseInt(tuple.getStringByField("affectedAccount"));

它工作正常,为什么即使值是整数也不工作呢?我猜第一列的类型实际上不是整数,而是字符串。看看Tuple.getIntegerByField的实现


原因是this.affectedAccount=Integer.parseInt(tuple.getStringByField(“affectedAccount”)的作用在于字段实际上是字符串类型。

您所说的“字段实际上是字符串类型”是什么意思?我可以看到它被实现为返回(整数)值;那么我在哪里可以设置字段类型呢?我的意思是,您从中接收元组的喷口(或其他螺栓?)在“affectedAccount”字段中放入了一个字符串,而不是一个整数(因此
“1”
而不是
1
)。您必须查看上游的bolt/Spoot以了解如何更改类型。Spoot只是读取一个文件并发送其内容,我还重写了DeclareoutpFields方法。好的,但是您在Spoot中输入值的第一个参数的对象的Java类型是int/Integer吗?