Pergunta

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.

Foi útil?

Solução

You need to override toString() of DoubleArrayWritable:

@Override
public String toString()
{
    // return the string you want
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top