【问题标题】:Writable Issue: Not able to print the contents可写问题:无法打印内容
【发布时间】:2013-11-06 20:16:33
【问题描述】:

reducer 的输入值是一个双精度数组。

719.000 501.000 -75.000
 501.000 508.000 -62.000
 -75.000 -62.000 10.000

在我的减速器中我需要打印这个矩阵。所以我做了

public void reduce(IntWritable key,
            Iterable<DoubleArrayWritable> values, Context context)
            throws IOException, InterruptedException {

            System.out.println("in reducer");
            for (DoubleArrayWritable  c :values) { // TODO - test me 
                System.out.println("C ="+c.toString());
}
}

DoubleArrayWritable 在哪里

public static class DoubleArrayWritable extends TwoDArrayWritable {
        public DoubleArrayWritable() {
            super(DoubleWritable.class);
        }
    }

我的输出是C =edu.Driver$DoubleArrayWritable@32d16fe3 但我需要以人类可读的格式打印整个矩阵。

【问题讨论】:

    标签: java hadoop mapreduce writable


    【解决方案1】:

    您需要覆盖toString() of DoubleArrayWritable

    @Override
    public String toString()
    {
        // return the string you want
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-19
      • 2017-01-27
      相关资源
      最近更新 更多