Class KvFileEntry

java.lang.Object
io.datarouter.bytes.kvfile.KvFileEntry

public class KvFileEntry extends Object
A generic KeyValue, plus a version represented as bytes. Entries are compared by key+version. Empty fields: - A key is generally required for any useful workload. - The version can be an empty byte[] if keys are unique. - The value can be an empty byte[] if all information is contained in the key. The bytes are interpreted lexicographically using Arrays::compareUnsigned. Many of these can be written to an OutputStream to be persisted for backup or further processing. Encodes KvFileEntry objects to bytes using the format: - varInt: total length of the all following fields - the total length is redundant, but can help split the InputStream faster for passing decoding to other threads - it can also help identify corruption, if the lengths don't add up - varInt: keyLength - bytes: key - varInt: versionLength - bytes: version - byte: opType - varInt: valueLength - bytes: value
  • Constructor Details

    • KvFileEntry

      public KvFileEntry(byte[] bytes, int offset, int length, int keyOffset, int keyLength, int versionOffset, int versionLength, KvFileOp op, int valueOffset, int valueLength)
  • Method Details

    • create

      public static KvFileEntry create(byte[] key, byte[] version, KvFileOp op, byte[] value)
    • putWithLongVersion

      public static KvFileEntry putWithLongVersion(byte[] key, long version, byte[] value)
    • equalsKeyOptimized

      public static boolean equalsKeyOptimized(KvFileEntry left, KvFileEntry right)
    • equalsVersion

      public static boolean equalsVersion(KvFileEntry left, KvFileEntry right)
    • compareKey

      public static int compareKey(KvFileEntry left, KvFileEntry right)
    • compareVersion

      public static int compareVersion(KvFileEntry left, KvFileEntry right)
    • compareKeyVersionOpOptimized

      public static int compareKeyVersionOpOptimized(KvFileEntry left, KvFileEntry right)
    • backingBytes

      public byte[] backingBytes()
    • copyOfBytes

      public byte[] copyOfBytes()
    • offset

      public int offset()
    • length

      public int length()
    • copyOfKey

      public byte[] copyOfKey()
    • copyOfVersion

      public byte[] copyOfVersion()
    • op

      public KvFileOp op()
    • copyOfValue

      public byte[] copyOfValue()
    • toString

      public String toString()
      Overrides:
      toString in class Object