Package oracle.kv
Class Version
- java.lang.Object
-
- oracle.kv.Version
-
- All Implemented Interfaces:
Serializable
,oracle.kv.impl.util.FastExternalizable
public class Version extends Object implements oracle.kv.impl.util.FastExternalizable, 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:-
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
ordeleteIfVersion
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. -
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
. SeeConsistency.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
ordeleteIfVersion
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(Object other)
static Version
fromByteArray(byte[] versionBytes)
Deserializes the given bytes that were returned earlier bytoByteArray()
and returns the resulting Version.int
hashCode()
byte[]
toByteArray()
Returns this Version as a serialized byte array, such thatfromByteArray(byte[])
may be used to reconstitute the Version.String
toString()
-
-
-
Method Detail
-
toByteArray
public byte[] toByteArray()
Returns this Version as a serialized byte array, such thatfromByteArray(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 bytoByteArray()
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 bytoByteArray()
- Returns:
- a new Version object
- Throws:
IllegalArgumentException
- if versionBytes is null or corrupted
-
-