Package org.apache.hadoop.io
Class ArrayPrimitiveWritable
java.lang.Object
org.apache.hadoop.io.ArrayPrimitiveWritable
- All Implemented Interfaces:
Writable
This is a wrapper class. It wraps a Writable implementation around
an array of primitives (e.g., int[], long[], etc.), with optimized
wire format, and without creating new objects per element.
This is a wrapper class only; it does not make a copy of the
underlying array.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty instance, for use during Writable readArrayPrimitiveWritable(Class<?> componentType) Construct an instance of known type but no value yet for use with type-specific wrapper classes.ArrayPrimitiveWritable(Object value) Wrap an existing array of primitives -
Method Summary
Modifier and TypeMethodDescriptionget()Get the original array.Class<?>Class<?>booleanisDeclaredComponentType(Class<?> componentType) voidreadFields(DataInput in) Deserialize the fields of this object fromin.voidvoidwrite(DataOutput out) Serialize the fields of this object toout.
-
Constructor Details
-
ArrayPrimitiveWritable
public ArrayPrimitiveWritable()Construct an empty instance, for use during Writable read -
ArrayPrimitiveWritable
Construct an instance of known type but no value yet for use with type-specific wrapper classes.- Parameters:
componentType- componentType.
-
ArrayPrimitiveWritable
Wrap an existing array of primitives- Parameters:
value- - array of primitives
-
-
Method Details
-
get
Get the original array. Client must cast it back to type componentType[] (or may use type-specific wrapper classes).- Returns:
- - original array as Object
-
getComponentType
-
getDeclaredComponentType
-
isDeclaredComponentType
-
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.
-