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 comparableByteSource
. 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ByteComparable.Version
-
Field Summary
Fields Modifier and Type Field Description static ByteComparable
EMPTY
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ByteSource
asComparableBytes(ByteComparable.Version version)
Returns a source that generates the byte-comparable representation of the value byte by byte.default java.lang.String
byteComparableAsString(ByteComparable.Version version)
Construct a human-readable string from the byte-comparable representation.static int
compare(ByteComparable bytes1, ByteComparable bytes2, ByteComparable.Version version)
Compare two byte-comparable values by their byte-comparable representation.static ByteComparable
cut(ByteComparable src, int cutoff)
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.static ByteComparable
fixedLength(byte[] bytes)
static ByteComparable
fixedLength(byte[] bytes, int offset, int len)
static ByteComparable
fixedLength(java.nio.ByteBuffer bytes)
static int
length(ByteComparable src, ByteComparable.Version version)
Return the length of a byte comparable, not including the terminator byte.static ByteComparable
of(int value)
static ByteComparable
of(long value)
static ByteComparable
of(java.lang.String s)
static ByteComparable
separatorGt(ByteComparable prevMax, ByteComparable currMin)
Returns a separator for two byte comparable, i.e.static ByteComparable
separatorPrefix(ByteComparable prevMax, ByteComparable currMin)
Returns a separator for two byte sources, i.e.
-
-
-
Field Detail
-
EMPTY
static final ByteComparable EMPTY
-
-
Method Detail
-
asComparableBytes
ByteSource asComparableBytes(ByteComparable.Version version)
Returns a source that generates the byte-comparable representation of the value byte by byte.
-
byteComparableAsString
default java.lang.String byteComparableAsString(ByteComparable.Version version)
Construct a human-readable string from the byte-comparable representation. Used for debugging.
-
of
static ByteComparable of(java.lang.String s)
-
of
static ByteComparable of(long value)
-
of
static ByteComparable of(int value)
-
fixedLength
static ByteComparable fixedLength(java.nio.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.
-
-