ArrayWritable does not implement WritableComparable, so it can't currently
be used as a mapper output key - those keys have to be sorted during the
shuffle, and thus the type must be WritableComparable.
通常对于发出键,我们使用定制的可写类。 为此,您应该在driver类public class driver中定义相同的{
public static class DoubleArrayWritable extends ArrayWritable {
public DoubleArrayWritable() {
super(DoubleWritable.class);
}
}
public static void main(String[] args) {
在mapper中
DoubleArrayWritable pointArray = new DoubleArrayWritable();
DoubleWritable[] data = new DoubleWritable[numAttributes];
for (int k = 0; k < numAttributes; k++) {
data[k] = new DoubleWritable(point[k]);
}
pointArray.set(data);
context.write(new Text("Array"), pointArray);
1条答案
按热度按时间hpcdzsge1#
可以使用
ArrayWritable
。我不确定在发射数组中作为键,下面是如何发射相同的作为值。通常对于发出键,我们使用定制的可写类。
为此,您应该在driver类public class driver中定义相同的{
在mapper中
希望这在某些方面有所帮助。