Search

How do we create Writable arrays in Hadoop ?



Hadoop provides two types of Writable data types for arrays. For one dimensional arrays, ArrayWritable and for two dimensional arrays, TwoDArrayWritable data types are available.
The elements of these arrays must be other writable objects like IntWritable or LongWritable only but not the java native data types like int or float. For example, below is implementation of array of IntWritables.

public static class IntArrayWritable extends ArrayWritable 
{
   public IntArrayWritable()
   {
      super(IntWritable.class) ;
   }
}