Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, to implement a custom key you must implement <code>WritableComparable</code>. To implement a custom value you must implement <code>Writable</code>. In many cases since it is handy to be able to swap keys and values most people write all custom types as <code>WritableComparable</code>.</p> <p>Here is a link to the section of <code>Hadoop: The Definitive Guide</code> that covers writing a <code>WritableComparable</code>. <a href="http://my.safaribooksonline.com/book/databases/hadoop/9780596521974/serialization/id3548156" rel="nofollow">Writing A Custom Writable</a></p> <p>The trick with writing out an array is that on the read side you need to know how many elements to read. So the basic patter is...</p> <pre><code>On write: write the number of elements write each element On read: read the number of elements (n) create an array of the appropriate size read 0 - (n-1) elements and populate array </code></pre> <p><strong>Update</strong></p> <p>You should instantiate your array as empty in the default constructor to prevent a NullPointerException later.</p> <p>The problem with your implementation is that it assumes that each inner array is of the same length. If that is true, you don't need to calculate the column length more than once. If false, you need to write the length of each row before writing the values of the row.</p> <p>I would suggest something like this:</p> <pre><code> context.write(row); // as calculated above for (int i=0; i&lt;row; i++){ double[] rowVals = array[row]; context.write(rowVals.length); for (int j=0; j&lt;rowVals.length; j++) context.write(rowVals[j]); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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