Search

How to create multiple value type output from Mapper with IntWritable and Text Writable ?



Write a class extending the org.apache.hadoop.io.GenericWritable class. Implement the getTypes() method to return an array of the Writable classes.

MultipleValueWritable.java

public class MultipleValueWritable extends GenericWritable
{
  private static Class[] types = new Class[]
                                 {
                                   IntWritable.class,
                                   Text.class
                                 };
  public MultipleValueWritable(Writable value)
  {
    set(value);
  }
  protected Class[] getTypes()
  {
    return types;
  }