Interface ByteComparable

All Known Subinterfaces:
PartitionPosition, PrimaryKey
All Known Implementing Classes:
BufferDecoratedKey, CachedHashDecoratedKey, DecoratedKey, NativeDecoratedKey, PreHashedDecoratedKey, Token.KeyBound

public interface ByteComparable
Interface indicating a value can be represented/identified by a comparable ByteSource. All Cassandra types that can be used as part of a primary key have a corresponding byte-comparable translation, detailed in ByteComparable.md. Byte-comparable representations are used in some memtable as well as primary and secondary index implementations.
  • Field Details

  • Method Details

    • asComparableBytes

      ByteSource asComparableBytes(ByteComparable.Version version)
      Returns a source that generates the byte-comparable representation of the value byte by byte.
    • byteComparableAsString

      default String byteComparableAsString(ByteComparable.Version version)
      Construct a human-readable string from the byte-comparable representation. Used for debugging.
    • of

      static ByteComparable of(String s)
    • of

      static ByteComparable of(long value)
    • of

      static ByteComparable of(int value)
    • fixedLength

      static ByteComparable fixedLength(ByteBuffer bytes)
    • fixedLength

      static ByteComparable fixedLength(byte[] bytes)
    • fixedLength

      static ByteComparable fixedLength(byte[] bytes, int offset, int len)
    • separatorPrefix

      static ByteComparable separatorPrefix(ByteComparable prevMax, ByteComparable currMin)
      Returns a separator for two byte sources, i.e. something that is definitely > prevMax, and <= currMin, assuming prevMax < currMin. This returns the shortest prefix of currMin that is greater than prevMax.
    • separatorGt

      static ByteComparable separatorGt(ByteComparable prevMax, ByteComparable currMin)
      Returns a separator for two byte comparable, i.e. something that is definitely > prevMax, and <= currMin, assuming prevMax < currMin. This is a stream of length 1 longer than the common prefix of the two streams, with last byte one higher than the prevMax stream.
    • cut

      static ByteComparable cut(ByteComparable src, int cutoff)
    • length

      static int length(ByteComparable src, ByteComparable.Version version)
      Return the length of a byte comparable, not including the terminator byte.
    • compare

      static int compare(ByteComparable bytes1, ByteComparable bytes2, ByteComparable.Version version)
      Compare two byte-comparable values by their byte-comparable representation. Used for tests.
      Returns:
      the result of the lexicographic unsigned byte comparison of the byte-comparable representations of the two arguments
    • diffPoint

      static int diffPoint(ByteComparable bytes1, ByteComparable bytes2, ByteComparable.Version version)
      Returns the length of the minimum prefix that differentiates the two given byte-comparable representations.