org.apache.hadoop.io

## Class ArrayPrimitiveWritable

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

- All Implemented Interfaces:
    Writable

      @InterfaceAudience.Public
       @InterfaceStability.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 and 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

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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 Detail

    - #### 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

    - #### ArrayPrimitiveWritable

          public ArrayPrimitiveWritable(Object value)

      Wrap an existing array of primitives
      Parameters:
        `value` - - array of primitives

  - ### Method Detail

    - #### 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`

    - #### 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`

Copyright © 2022 Apache Software Foundation. All rights reserved.