Package org.apache.hadoop.io
Class ObjectWritable
java.lang.Object
org.apache.hadoop.io.ObjectWritable
- All Implemented Interfaces:
Configurable,Writable
A polymorphic Writable that writes an instance with it's class name.
Handles arrays, strings and primitive types without a Writable wrapper.
-
Constructor Summary
ConstructorsConstructorDescriptionObjectWritable(Class declaredClass, Object instance) ObjectWritable(Object instance) -
Method Summary
Modifier and TypeMethodDescriptionget()Return the instance, or null if none.getConf()Return the configuration used by this object.Return the class this is meant to be.static Class<?>loadClass(Configuration conf, String className) Find and load the class with given nameclassNameby first finding it in the specifiedconf.voidreadFields(DataInput in) Deserialize the fields of this object fromin.static ObjectreadObject(DataInput in, Configuration conf) static ObjectreadObject(DataInput in, ObjectWritable objectWritable, Configuration conf) voidReset the instance.voidsetConf(Configuration conf) Set the configuration to be used by this object.toString()voidwrite(DataOutput out) Serialize the fields of this object toout.static voidwriteObject(DataOutput out, Object instance, Class declaredClass, Configuration conf) static voidwriteObject(DataOutput out, Object instance, Class declaredClass, Configuration conf, boolean allowCompactArrays)
-
Constructor Details
-
ObjectWritable
public ObjectWritable() -
ObjectWritable
-
ObjectWritable
-
-
Method Details
-
get
Return the instance, or null if none.- Returns:
- the instance, or null if none.
-
getDeclaredClass
Return the class this is meant to be.- Returns:
- the class this is meant to be.
-
set
Reset the instance.- Parameters:
instance- instance.
-
toString
-
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.
-
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.
-
writeObject
public static void writeObject(DataOutput out, Object instance, Class declaredClass, Configuration conf) throws IOException - Parameters:
out- DataOutput.instance- instance.conf- Configuration.declaredClass- declaredClass.- Throws:
IOException- raised on errors performing I/O.
-
writeObject
public static void writeObject(DataOutput out, Object instance, Class declaredClass, Configuration conf, boolean allowCompactArrays) throws IOException - Parameters:
allowCompactArrays- - set true for RPC and internal or intra-cluster usages. Set false for inter-cluster, File, and other persisted output usages, to preserve the ability to interchange files with other clusters that may not be running the same version of software. Sometime in ~2013 we can consider removing this parameter and always using the compact format.conf- configuration.out- dataoutput.declaredClass- declaredClass.instance- instance.- Throws:
IOException- raised on errors performing I/O.
-
readObject
- Parameters:
conf- configuration.in- DataInput.- Returns:
- Object.
- Throws:
IOException- raised on errors performing I/O.
-
readObject
public static Object readObject(DataInput in, ObjectWritable objectWritable, Configuration conf) throws IOException - Parameters:
in- DataInput.objectWritable- objectWritable.conf- configuration.- Returns:
- Object.
- Throws:
IOException- raised on errors performing I/O.
-
loadClass
Find and load the class with given nameclassNameby first finding it in the specifiedconf. If the specifiedconfis null, try load it directly.- Parameters:
conf- configuration.className- classname.- Returns:
- Class.
-
setConf
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Parameters:
conf- configuration to be used
-
getConf
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Returns:
- Configuration
-