oracle.kv

## Class Version

- java.lang.Object
- - oracle.kv.Version

- All Implemented Interfaces:
    oracle.kv.impl.util.FastExternalizable

      public class Version
      extends Object
      implements oracle.kv.impl.util.FastExternalizable

  A Version refers to a specific version of a key-value pair.

  When a key-value pair is initially inserted in the KV Store, and each time it is updated, it is assigned a unique version token. The version is always returned by the put method, for example, `put`, and is also returned by get methods, for example, `get`. The version is important for two reasons:

  1. When an update or delete is to be performed, it may be important to only perform the update or delete if the last known value has not changed. For example, if an integer field in a previously known value is to be incremented, it is important that the previous value has not changed in the KV Store since it was obtained by the client. This can be guaranteed by passing the version of the previously known value to the `putIfVersion` or `deleteIfVersion` method. If the version specified does not match the current version of the value in the KV Store, these methods will not perform the update or delete operation and will return an indication of failure. Optionally, they will also return the current version and/or value so the client can retry the operation or take a different action.
  2. When a client reads a value that was previously written, it may be important to ensure that the KV Store node servicing the read operation has been updated with the information previously written. This can be accomplished by passing the version of the previously written value as a `Consistency` parameter to the read operation, for example, `get`. See `Consistency.Version` for more information.

  It is important to be aware that the system may infrequently assign a new Version to a key-value pair, for example, when migrating data for better resource usage. Therefore, when using the `putIfVersion` or `deleteIfVersion` methods, one cannot assume that the Version will remain constant until it is changed by the application.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object other)`
    `static Version` | `fromByteArray(byte[] keyBytes)` Deserializes the given bytes that were returned earlier by `toByteArray()` and returns the resulting Version.
    `long` | `getVersion()` For an implied Key associated with this Version, returns a unique identifier for this Version.
    `int` | `hashCode()`
    `byte[]` | `toByteArray()` Returns this Version as a serialized byte array, such that `fromByteArray(byte[])` may be used to reconstitute the Version.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface oracle.kv.impl.util.FastExternalizable

      `writeFastExternal`

- - ### Method Detail

    - #### toByteArray

          public byte[] toByteArray()

      Returns this Version as a serialized byte array, such that `fromByteArray(byte[])` may be used to reconstitute the Version.

    - #### fromByteArray

          public static Version fromByteArray(byte[] keyBytes)

      Deserializes the given bytes that were returned earlier by `toByteArray()` and returns the resulting Version.

    - #### getVersion

          public long getVersion()

      For an implied Key associated with this Version, returns a unique identifier for this Version.

    - #### equals

          public boolean equals(Object other)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.