Java 为什么apache storm中CombinerAggregator/ReducerAggregator的元组大小始终为0

Java 为什么apache storm中CombinerAggregator/ReducerAggregator的元组大小始终为0,java,apache-storm,Java,Apache Storm,我最近开始使用storm Trident,在阅读storm文档时,遇到了一个难以理解的问题,下面是我的代码 //TestGlobalAggregatorTopo 公共类TestGlobalAggregatorTopo{ 公共静态StormTopology buildTopology(){ TridentTopology=新的TridentTopology(); FixedBatchSpoot=新的FixedBatchSpoot(新字段(“句子”),2, 新的价值观(“奶牛跳过了月球”), 新价值

我最近开始使用storm Trident,在阅读storm文档时,遇到了一个难以理解的问题,下面是我的代码

//TestGlobalAggregatorTopo
公共类TestGlobalAggregatorTopo{
公共静态StormTopology buildTopology(){
TridentTopology=新的TridentTopology();
FixedBatchSpoot=新的FixedBatchSpoot(新字段(“句子”),2,
新的价值观(“奶牛跳过了月球”),
新价值观(“该男子去商店买了一些糖果”),
新价值观(“四十七年前”),
新的价值观(“你吃了多少苹果糖”);
喷口设置周期(假);
topology.newStream(“喷口”,喷口).parallelismHint(1)
.each(新字段(“句子”)、新拆分函数()、新字段(“单词”))
//.each(新字段(“句子”)、新OutputFunction()、新字段(“”)
.groupBy(新字段(“word”))
.persistentAggregate(新的MemoryMapState.Factory(),新的CountCombinerAggregator(),新的字段(“计数”))
.newValuesStream()
.peek(新消费者){
@凌驾
公共void接受(三元组输入){
String v=String.format(“word=[%s],count=[%s]”,input.get(0),input.get(1));
系统输出打印Ln(v);
}
});
返回topology.build();
}
公共静态void main(字符串[]args){
Config=new Config();
config.setDebug(false);
LocalCluster LocalCluster=新的LocalCluster();
submitTopology(“聚合器”,配置,buildTopology());
}
}
//CountCombinerAggregator
公共类CountCombinerAggregator实现CombinerAggregator{
私有静态最终长serialVersionUID=-8503208039535179201L;
私有静态最终记录器LOG=LoggerFactory.getLogger(CountCombinerAggregator.class);
@凌驾
公共PersistentCountState初始化(三元组){
LOG.info(“tuple.size=[{}]”,tuple.size();
返回新的PersistentCountState(1);
}
@凌驾
公共PersistentCountState组合(PersistentCountState值1,PersistentCountState值2){
int cnt=val1.getCount()+val2.getCount();
PersistentCountState=新的PersistentCountState(1);
state.setCount(cnt);
返回状态;
}
@凌驾
公共PersistentCountState零(){
返回新的PersistentCountState(0);
}
}
代码非常简单,FixedBatchSpoot发出元组和SplitFunction将句子拆分为单词,然后CountCombinerAggregator进行单词计数

但是,我在CombinerAggregator中遇到了一个问题,ʻinit`方法中的
TridentTuple tuple
的大小始终为零

如中所述:

CombinerAggregator返回一个元组,其中一个字段作为输出combineraggrators对每个输入元组运行init函数,并使用combine函数组合值,直到只剩下一个值。如果分区中没有元组,CombinerAggregator将发出zero函数的输出。例如,下面是Count的实现:

所以我的问题是:为什么ʻinit`方法中的
TridentTuple tuple
的大小总是零