Package oracle.kv

Class Version

  • All Implemented Interfaces:
    java.io.Serializable, oracle.kv.impl.util.FastExternalizable

    public class Version
    extends java.lang.Object
    implements oracle.kv.impl.util.FastExternalizable, java.io.Serializable
    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.

    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)  
      static Version fromByteArray​(byte[] versionBytes)
      Deserializes the given bytes that were returned earlier by toByteArray() and returns the resulting Version.
      int hashCode()  
      byte[] toByteArray()
      Returns this Version as a serialized byte array, such that fromByteArray(byte[]) may be used to reconstitute the Version.
      java.lang.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

        deserializedForm
    • 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. Values returned by calls to this method can be used with current and newer releases, but are not guaranteed to be compatible with earlier releases.
      • fromByteArray

        public static Version fromByteArray​(byte[] versionBytes)
        Deserializes the given bytes that were returned earlier by toByteArray() and returns the resulting Version. Values created with either the current or earlier releases can be used with this method, but values created by later releases are not guaranteed to be compatible.
        Parameters:
        versionBytes - a byte array produced by toByteArray()
        Returns:
        a new Version object
        Throws:
        java.lang.IllegalArgumentException - if versionBytes is null or corrupted
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object