public final class ByteKey extends Object implements Comparable<ByteKey>, 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[]. |
boolean |
equals(Object o) |
byte[] |
getBytes()
Returns a newly-allocated
byte[] representing this ByteKey. |
com.google.protobuf.ByteString |
getValue()
Returns an immutable
ByteString representing this ByteKey. |
int |
hashCode() |
boolean |
isEmpty()
|
static ByteKey |
of(com.google.protobuf.ByteString value)
Creates a new
ByteKey backed by the specified ByteString. |
static ByteKey |
of(int... bytes)
Creates a new
ByteKey backed by a copy of the specified int[]. |
String |
toString() |
public static final ByteKey EMPTY
public static ByteKey of(com.google.protobuf.ByteString value)
ByteKey backed by the specified ByteString.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 com.google.protobuf.ByteString getValue()
public byte[] getBytes()
public boolean isEmpty()
public int compareTo(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 Comparable<ByteKey>