org.apache.hadoop.io

## Class VersionedWritable

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

- All Implemented Interfaces:
    Writable

      @InterfaceAudience.Public
       @InterfaceStability.Stable
      public abstract class VersionedWritable
      extends Object
      implements Writable

  A base class for Writables that provides version checking.

  This is useful when a class may evolve, so that instances written by the old version of the class may still be processed by the new version. To handle this situation, `readFields(DataInput)` implementations should catch `VersionMismatchException`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `VersionedWritable()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract byte` | `getVersion()` Return the version number of the current implementation.
    `void` | `readFields(DataInput in)` Deserialize the fields of this object from `in`.
    `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

    - #### VersionedWritable

          public VersionedWritable()

  - ### Method Detail

    - #### getVersion

          public abstract byte getVersion()

      Return the version number of the current implementation.

    - #### 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 © 2008–2022 Apache Software Foundation. All rights reserved.