My input value to reducer is a double array.

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

In my reducer i need to print this matrix.so i did

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());
}
}

where DoubleArrayWritable is

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

My output is C =edu.Driver$DoubleArrayWritable@32d16fe3 But i need to print entire matrix in human readable format.

有帮助吗?

解决方案

You need to override toString() of DoubleArrayWritable:

@Override
public String toString()
{
    // return the string you want
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top