Class ArrayWritable

java.lang.Object
org.apache.hadoop.io.ArrayWritable
All Implemented Interfaces:
Writable

@Public @Stable public class ArrayWritable extends Object implements Writable
A Writable for arrays containing instances of a class. The elements of this writable must all be instances of the same class. If this writable will be the input for a Reducer, you will need to create a subclass that sets the value to be of the proper type. For example: public class IntArrayWritable extends ArrayWritable { public IntArrayWritable() { super(IntWritable.class); } }
  • Constructor Details

    • ArrayWritable

      public ArrayWritable(Class<? extends Writable> valueClass)
    • ArrayWritable

      public ArrayWritable(Class<? extends Writable> valueClass, Writable[] values)
    • ArrayWritable

      public ArrayWritable(String[] strings)
  • Method Details

    • getValueClass

      public Class<? extends Writable> getValueClass()
    • toStrings

      public String[] toStrings()
    • toArray

      public Object toArray()
    • set

      public void set(Writable[] values)
    • get

      public Writable[] get()
    • readFields

      public void readFields(DataInput in) throws IOException
      Description copied from interface: Writable
      Deserialize the fields of this object from in.

      For efficiency, implementations should attempt to re-use storage in the existing object where possible.

      Specified by:
      readFields in interface Writable
      Parameters:
      in - DataInput to deseriablize this object from.
      Throws:
      IOException - any other problem for readFields.
    • write

      public void write(DataOutput out) throws IOException
      Description copied from interface: Writable
      Serialize the fields of this object to out.
      Specified by:
      write in interface Writable
      Parameters:
      out - DataOuput to serialize this object into.
      Throws:
      IOException - any other problem for write.
    • toString

      public String toString()
      Overrides:
      toString in class Object