public final class ByteKey extends java.lang.Object implements java.lang.Comparable<ByteKey>, java.io.Serializable
byte[]
keys
are typical in key-value stores such as Google Cloud Bigtable.
Instances of ByteKey
are immutable.
ByteKey
implements Comparable<ByteKey>
by comparing the
arrays in lexicographic order. The smallest ByteKey
is a zero-length array; the successor
to a key is the same key with an additional 0 byte appended; and keys have unbounded size.
Note that the empty ByteKey
compares smaller than all other keys, but some systems
have the semantic that when an empty ByteKey
is used as an upper bound, it represents the
largest possible key. In these cases, implementors should use isEmpty()
to test whether an
upper bound key is empty.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ByteKey other)
ByteKey implements Comparable<ByteKey> by comparing the arrays
in lexicographic order. |
static ByteKey |
copyFrom(byte[] bytes)
Creates a new
ByteKey backed by a copy of the specified byte[] . |
static ByteKey |
copyFrom(java.nio.ByteBuffer value)
Creates a new
ByteKey backed by a copy of the data remaining in the specified ByteBuffer . |
boolean |
equals(java.lang.Object o) |
byte[] |
getBytes()
Returns a newly-allocated
byte[] representing this ByteKey . |
java.nio.ByteBuffer |
getValue()
Returns a read-only
ByteBuffer representing this ByteKey . |
int |
hashCode() |
boolean |
isEmpty()
|
static ByteKey |
of(int... bytes)
Creates a new
ByteKey backed by a copy of the specified int[] . |
java.lang.String |
toString() |
public static final ByteKey EMPTY
public static ByteKey copyFrom(java.nio.ByteBuffer value)
ByteKey
backed by a copy of the data remaining in the specified ByteBuffer
.public static ByteKey copyFrom(byte[] bytes)
ByteKey
backed by a copy of the specified byte[]
.
Makes a copy of the underlying array.
public static ByteKey of(int... bytes)
public java.nio.ByteBuffer getValue()
ByteBuffer
representing this ByteKey
.public byte[] getBytes()
public boolean isEmpty()
public int compareTo(@Nonnull ByteKey other)
ByteKey
implements Comparable<ByteKey>
by comparing the arrays
in lexicographic order. The smallest ByteKey
is a zero-length array; the successor to a
key is the same key with an additional 0 byte appended; and keys have unbounded size.compareTo
in interface java.lang.Comparable<ByteKey>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object