Package org.apache.beam.sdk.io.range
Class ByteKey
java.lang.Object
org.apache.beam.sdk.io.range.ByteKey
- All Implemented Interfaces:
Serializable
,Comparable<ByteKey>
A class representing a key consisting of an array of bytes. Arbitrary-length
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.
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
ByteKey
implementsComparable<ByteKey>
by comparing the arrays in lexicographic order.static ByteKey
copyFrom
(byte[] bytes) Creates a newByteKey
backed by a copy of the specifiedbyte[]
.static ByteKey
copyFrom
(ByteBuffer value) Creates a newByteKey
backed by a copy of the data remaining in the specifiedByteBuffer
.boolean
byte[]
getBytes()
Returns a newly-allocatedbyte[]
representing thisByteKey
.getValue()
Returns a read-onlyByteBuffer
representing thisByteKey
.int
hashCode()
boolean
isEmpty()
static ByteKey
of
(int... bytes) Creates a newByteKey
backed by a copy of the specifiedint[]
.toString()
-
Field Details
-
EMPTY
An empty key.
-
-
Method Details
-
copyFrom
Creates a newByteKey
backed by a copy of the data remaining in the specifiedByteBuffer
. -
copyFrom
Creates a newByteKey
backed by a copy of the specifiedbyte[]
.Makes a copy of the underlying array.
-
of
-
getValue
Returns a read-onlyByteBuffer
representing thisByteKey
. -
getBytes
public byte[] getBytes() -
isEmpty
public boolean isEmpty() -
compareTo
ByteKey
implementsComparable<ByteKey>
by comparing the arrays in lexicographic order. The smallestByteKey
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.- Specified by:
compareTo
in interfaceComparable<ByteKey>
-
toString
-
equals
-
hashCode
public int hashCode()
-