ArrayWritable contstructor

时间:2016-01-08 23:23:26

标签: java hadoop constructor mapreduce writable

我试图创建一个由两个步骤组成的mapreduce链。第一个reduce将键值对发出为(键,值),其中value是自定义对象的列表,第二个映射器应读取第一个reducer的输出。该列表是一个自定义ArrayWritable。以下是相关代码:

 class MyArrayWritable extends ArrayWritable {  

    public MyArrayWritable() {
        super(Custom.class);
    }

    public MyArrayWritable(Writable[] values) {
        super(Custom.class, values);
    }

    @Override
    public Custom[] get() {
        return (Custom[]) super.get();
    }

    @Override
    public String toString() {
      return Arrays.toString(get());
    }

    @Override
    public void write(DataOutput arg0) throws IOException {
        super.write(arg0);
    }
}

第二个映射器(将自定义可编写的值作为值):

 public static class SecondMapper extends Mapper<Text, MyArrayWritable, Text, IntWritable> {

    public void map(Text key, MyArrayWritable value, Context context) throws IOException, InterruptedException {
        //other code
        context.write(key, myNewWritableArray);
    }
}

当第二个作业开始时,我收到此错误:            错误:java.lang.RuntimeException:java.lang.NoSuchMethodException:Detector $ MyArrayWritable。&lt; init&gt;()

我该如何解决?我已经在MyArrayWritable

中实现了默认构造函数

0 个答案:

没有答案