Class CompressedWritable

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

@Public @Stable public abstract class CompressedWritable extends Object implements Writable
A base-class for Writables which store themselves compressed and lazily inflate on field access. This is useful for large objects whose fields are not be altered during a map or reduce operation: leaving the field data compressed makes copying the instance from one file to another much faster.
  • Constructor Details

    • CompressedWritable

      public CompressedWritable()
  • Method Details

    • readFields

      public final 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.
    • ensureInflated

      protected void ensureInflated()
      Must be called by all methods which access fields to ensure that the data has been uncompressed.
    • readFieldsCompressed

      protected abstract void readFieldsCompressed(DataInput in) throws IOException
      Subclasses implement this instead of readFields(DataInput).
      Parameters:
      in - data input.
      Throws:
      IOException - raised on errors performing I/O.
    • write

      public final 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.
    • writeCompressed

      protected abstract void writeCompressed(DataOutput out) throws IOException
      Subclasses implement this instead of write(DataOutput).
      Parameters:
      out - data output.
      Throws:
      IOException - raised on errors performing I/O.