Note that there are some explanatory texts on larger screens.

plurals
  1. POEmpty value in write() method : Custom Datatype in Hadoop MapReduce
    text
    copied!<p>I am emitting two 2D double arrays as key and value. I am constructing <code>WritableComparable</code> class.</p> <pre><code>public class MF implements WritableComparable&lt;MF&gt;{ /** * @param args */ private double[][] value; public MF() { // TODO Auto-generated constructor stub } public MF(double[][] value) { // TODO Auto-generated constructor stub this.value = new double[value.length][value[0].length]; // System.out.println("in matrix"); } public void set(double[][] value) { this.value = value; } public double[][] getValue() { return value; } @Override public void write(DataOutput out) throws IOException { System.out.println("write"); int row=0; int column=0; for(int i=0; i&lt;value.length;i++) { row = value.length; for(int j=0; j&lt;value[i].length; j++) { column = value[i].length; } } out.writeInt(row); out.writeInt(column); for(int i=0;i&lt;row ; i++) { for(int j= 0 ; j&lt; col;j++) { out.writeDouble(value[i][j]); } } for(int i =0;i&lt; value.length ;i ++) { for(int j = 0;j &lt;value[0].length;j++) { System.out.print(value[i][j]+ "\t"); } System.out.println(""); } } @Override public void readFields(DataInput in) throws IOException { int row = in.readInt(); int col = in.readInt(); double[][] value = new double[row][col]; for(int i=0;i&lt;row ; i++) { for(int j= 0 ; j&lt; col;j++) { value[i][j] = in.readDouble(); } } } @Override public int hashCode() { } @Override public boolean equals(Object o) { } @Override public int compareTo(MF o) { // TODO Auto-generated method stub return 0; } @Override public String toString() { System.out.println(Arrays.toString(value)); return Arrays.toString(value); } } </code></pre> <p>And half way through, when I tried to print my matrix within write method, the matrix is not having values</p> <pre><code>write 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 write 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 </code></pre> <p>I am doing something wrong. I am getting apt no of rows and cols.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload