我有两个来源的输入:
以表格形式输出地图,
output.collect(new StockKey(Text(x+" "+id), new Text(id2)), new Text(data));
以表格形式输出地图,
output.collect(new StockKey(new Text(x+" "+id), new Text(1), new Text(data));
工作配置:
conf.setPartitionerClass(CustomPartitioner.class);
conf.setValueGroupingComparatorClass(StockKeyGroupingComparator.class);
其中 StockKey 是 format 的自定义类(new Text(), new Text())
;
构造函数:
public StockKey(){
this.symbol = new Text();
this.timestamp = new Text();
}
分组比较器:
public class StockKeyGroupingComparator extends WritableComparator {
protected StockKeyGroupingComparator() {
super(StockKey.class, true);
}
public int compare(WritableComparable w1, WritableComparable w2){
StockKey k1 = (StockKey)w1;
StockKey k2 = (StockKey)w2;
Text x1 = new Text(k1.getSymbol());
Text x2 = new Text(k2.getSymbol());
return x1.compareTo(x2);
}
}
但我没有从输入接收地图输出值
我只得到地图输出值到达减速器。我希望将两个地图输出中共有的符号 viz 的记录new Text(x+" "+id)
分组到同一个 reducer。我在这里感到震惊。
请帮忙!