org.apache.hadoop.io
Class CompressedWritable

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

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 Summary
CompressedWritable()
           
 
Method Summary
protected  void ensureInflated()
          Must be called by all methods which access fields to ensure that the data has been uncompressed.
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
protected abstract  void readFieldsCompressed(DataInput in)
          Subclasses implement this instead of readFields(DataInput).
 void write(DataOutput out)
          Serialize the fields of this object to out.
protected abstract  void writeCompressed(DataOutput out)
          Subclasses implement this instead of write(DataOutput).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompressedWritable

public CompressedWritable()
Method Detail

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

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).

Throws:
IOException

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

writeCompressed

protected abstract void writeCompressed(DataOutput out)
                                 throws IOException
Subclasses implement this instead of write(DataOutput).

Throws:
IOException


Copyright © 2009 The Apache Software Foundation