Package oracle.kv

Class Value

java.lang.Object
oracle.kv.Value
All Implemented Interfaces:
oracle.kv.impl.util.FastExternalizable

public class Value extends Object implements oracle.kv.impl.util.FastExternalizable
The Value in a Key/Value store.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Identifies the format of a value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Value
    An instance that represents an empty value for key-only records.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Value
    createValue(byte[] val)
    Creates a Value from a value byte array.
    boolean
    equals(Object other)
     
    static Value
    fromByteArray(byte[] bytes)
    Deserializes the given bytes that were returned earlier by toByteArray() and returns the resulting Value.
    Returns the value's format.
    static int
    Returns the regionId given the entire encoded row or Region.NULL_REGION_ID if not present.
    byte[]
    Returns the value byte array.
    static int
    getValueOffset(byte[] bytes)
    Returns the offset index (starts with 0) of the row value given the entire encoded row.
    int
     
    static boolean
    hasLastWriteMetadata(byte[] bytes)
    Returns true if there is a lastWriteMetadata in the entire encoded row, otherwise false.
    static boolean
    hasRegionId(byte[] bytes)
    Returns true if there is a regionId in the entire encoded row, otherwise false.
    static boolean
    isTombstone(byte[] bytes)
    Returns true if tombstone, i.e.
    static Value
    removeLastWriteMetadata(byte[] original)
    Converts by removing the last write metadata.
    static Value
    Converts by removing the last write metadata.
    static int
    setRegionIdAndLastWriteMetadata(byte[] bytes, oracle.kv.impl.api.table.RowImpl row)
    Sets regionId and lastWriteMetadata if available and returns the offset of row data.
    byte[]
    Returns this Value as a serialized byte array, such that fromByteArray(byte[]) may be used to reconstitute the Value.
     

    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
  • Field Details

    • EMPTY_VALUE

      public static final Value EMPTY_VALUE
      An instance that represents an empty value for key-only records.
  • Method Details

    • toByteArray

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

      The intended use case for the toByteArray() and fromByteArray(byte[]) methods is to serialize values of various formats in a uniform manner, for storage outside of NoSQL DB or for sending across a network.

      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.

      WARNING: The array returned by this method should be considered to be opaque by the caller. This array is not necessarily equal to the array returned by getValue(); in particular, the returned array may contain an extra byte identifying the format. The only valid use of this array is to pass it to fromByteArray(byte[]) at a later time in order to reconstruct the Value object. Normally getValue() should be used instead of this method.

      See Also:
    • fromByteArray

      public static Value fromByteArray(byte[] bytes)
      Deserializes the given bytes that were returned earlier by toByteArray() and returns the resulting Value.

      The intended use case for the toByteArray() and fromByteArray(byte[]) methods is to serialize values of various formats in a uniform manner, for storage outside of NoSQL DB or for sending across a network.

      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.

      WARNING: Misuse of this method could result in data corruption if the returned object is added to the store. The array passed to this method must have been previously created by calling fromByteArray(byte[]). To create a Value object of format Value.Format.NONE, call createValue(byte[]) instead.

      See Also:
    • createValue

      public static Value createValue(byte[] val)
      Creates a Value from a value byte array. The format of the returned value is Value.Format.NONE.
    • getValue

      public byte[] getValue()
      Returns the value byte array.
    • getFormat

      public Value.Format getFormat()
      Returns the value's format.
      Since:
      2.0
    • 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
    • isTombstone

      public static boolean isTombstone(byte[] bytes)
      Returns true if tombstone, i.e. it can contain regionId or lastWriteMetadata but payload (row data) is empty.
    • hasRegionId

      public static boolean hasRegionId(byte[] bytes)
      Returns true if there is a regionId in the entire encoded row, otherwise false.
    • hasLastWriteMetadata

      public static boolean hasLastWriteMetadata(byte[] bytes)
      Returns true if there is a lastWriteMetadata in the entire encoded row, otherwise false.
    • getRegionIdFromByteArray

      public static int getRegionIdFromByteArray(byte[] bytes)
      Returns the regionId given the entire encoded row or Region.NULL_REGION_ID if not present.
    • getValueOffset

      public static int getValueOffset(byte[] bytes)
      Returns the offset index (starts with 0) of the row value given the entire encoded row.
    • setRegionIdAndLastWriteMetadata

      public static int setRegionIdAndLastWriteMetadata(byte[] bytes, oracle.kv.impl.api.table.RowImpl row)
      Sets regionId and lastWriteMetadata if available and returns the offset of row data.
    • removeLastWriteMetadata

      public static Value removeLastWriteMetadata(Value original)
      Converts by removing the last write metadata. Convert to Value.Format.TABLE_V1. Note that we also have an old Value.Format.TABLE that is the same except for the serialization of json fields (see commit acf25d44). We should not serialize with that old format version. The TABLE_V1 format is introduced in R4.5 in 2017. Old clients that do not recognize this format should not exist anymore. Furthermore, currently the only method, that uses TABLE_V1 differently than TABLE, is TableImpl#getJsonSerialVersion. Inside the behavior of TABLE_V1 is the same as any versions afterward. That is, for any caller care about the difference between TABLE_V1 and TABLE, newer format version should behave as TABLE_V1.
    • removeLastWriteMetadata

      public static Value removeLastWriteMetadata(byte[] original)
      Converts by removing the last write metadata.