ArrayPrimitiveWritable (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io, class: ArrayPrimitiveWritable

Package org.apache.hadoop.io

# Class ArrayPrimitiveWritable

java.lang.Object
org.apache.hadoop.io.ArrayPrimitiveWritable

All Implemented Interfaces:
  `Writable`

@Public @Stable public class ArrayPrimitiveWritable extends Object implements 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

  Constructors
  Constructor
  Description
  `ArrayPrimitiveWritable()`
  Construct an empty instance, for use during Writable read
  `ArrayPrimitiveWritable(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 Type
  Method
  Description
  `Object`
  `get()`
  Get the original array.
  `Class<?>`
  `getComponentType()`
  `Class<?>`
  `getDeclaredComponentType()`
  `boolean`
  `isDeclaredComponentType(Class<?> componentType)`
  `void`
  `readFields(DataInput in)`
  Deserialize the fields of this object from `in`.
  `void`
  `set(Object value)`
  `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 Details

  - ### ArrayPrimitiveWritable

    public ArrayPrimitiveWritable()
    Construct an empty instance, for use during Writable read

  - ### ArrayPrimitiveWritable

    public ArrayPrimitiveWritable(Class<?> componentType)
    Construct an instance of known type but no value yet for use with type-specific wrapper classes.
    Parameters:
      `componentType` - componentType.

  - ### ArrayPrimitiveWritable

    public ArrayPrimitiveWritable(Object value)
    Wrap an existing array of primitives
    Parameters:
      `value` - - array of primitives

- ## Method Details

  - ### get

    public Object 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

    public Class<?> getComponentType()

  - ### getDeclaredComponentType

    public Class<?> getDeclaredComponentType()

  - ### isDeclaredComponentType

    public boolean isDeclaredComponentType(Class<?> componentType)

  - ### set

    public void set(Object value)

  - ### write

    public 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` - any other problem for write.

  - ### readFields

    public 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` - any other problem for readFields.