org.apache.hadoop.io
Class AbstractMapWritable

java.lang.Object
  extended by org.apache.hadoop.io.AbstractMapWritable
All Implemented Interfaces:
Configurable, Writable
Direct Known Subclasses:
MapWritable, SortedMapWritable

public abstract class AbstractMapWritable
extends Object
implements Writable, Configurable

Abstract base class for MapWritable and SortedMapWritable Unlike org.apache.nutch.crawl.MapWritable, this class allows creation of MapWritable<Writable, MapWritable> so the CLASS_TO_ID and ID_TO_CLASS maps travel with the class instead of being static. Class ids range from 1 to 127 so there can be at most 127 distinct classes in any specific map instance.


Constructor Summary
protected AbstractMapWritable()
          constructor.
 
Method Summary
protected  void addToMap(Class clazz)
          Add a Class to the maps if it is not already present.
protected  void copy(Writable other)
          Used by child copy constructors.
protected  Class getClass(byte id)
           
 Configuration getConf()
          Return the configuration used by this object.
protected  byte getId(Class clazz)
           
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 void setConf(Configuration conf)
          Set the configuration to be used by this object.
 void write(DataOutput out)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMapWritable

protected AbstractMapWritable()
constructor.

Method Detail

addToMap

protected void addToMap(Class clazz)
Add a Class to the maps if it is not already present.


getClass

protected Class getClass(byte id)
Returns:
the Class class for the specified id

getId

protected byte getId(Class clazz)
Returns:
the id for the specified Class

copy

protected void copy(Writable other)
Used by child copy constructors.


getConf

public Configuration getConf()
Description copied from interface: Configurable
Return the configuration used by this object.

Specified by:
getConf in interface Configurable
Returns:
the conf

setConf

public void setConf(Configuration conf)
Description copied from interface: Configurable
Set the configuration to be used by this object.

Specified by:
setConf in interface Configurable
Parameters:
conf - the conf to set

write

public void write(DataOutput out)
           throws IOException
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
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


Copyright © 2009 The Apache Software Foundation