Package org.apache.hadoop.io
Class AbstractMapWritable
java.lang.Object
org.apache.hadoop.io.AbstractMapWritable
- All Implemented Interfaces:
Configurable,Writable
- Direct Known Subclasses:
MapWritable,SortedMapWritable
@Public
@Stable
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd a Class to the maps if it is not already present.protected voidUsed by child copy constructors.protected Class<?>getClass(byte id) the Class class for the specified id.getConf()Return the configuration used by this object.protected byteget id.voidreadFields(DataInput in) Deserialize the fields of this object fromin.voidsetConf(Configuration conf) Set the configuration to be used by this object.voidwrite(DataOutput out) Serialize the fields of this object toout.
-
Constructor Details
-
AbstractMapWritable
protected AbstractMapWritable()constructor.
-
-
Method Details
-
addToMap
Add a Class to the maps if it is not already present.- Parameters:
clazz- clazz.
-
getClass
the Class class for the specified id.- Parameters:
id- id.- Returns:
- the Class class for the specified id.
-
getId
get id.- Parameters:
clazz- clazz.- Returns:
- the id for the specified Class.
-
copy
Used by child copy constructors.- Parameters:
other- other.
-
getConf
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Returns:
- the conf
-
setConf
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Parameters:
conf- the conf to set
-
write
Description copied from interface:WritableSerialize the fields of this object toout.- Specified by:
writein interfaceWritable- Parameters:
out-DataOuputto serialize this object into.- Throws:
IOException- any other problem for write.
-
readFields
Description copied from interface:WritableDeserialize the fields of this object fromin.For efficiency, implementations should attempt to re-use storage in the existing object where possible.
- Specified by:
readFieldsin interfaceWritable- Parameters:
in-DataInputto deseriablize this object from.- Throws:
IOException- any other problem for readFields.
-