com.google.cloud.dataflow.sdk.io.range

## Class ByteKey

- java.lang.Object
- - com.google.cloud.dataflow.sdk.io.range.ByteKey

All Implemented Interfaces:
  Serializable, Comparable<ByteKey>

    public final class ByteKey
    extends Object
    implements Comparable<ByteKey>, Serializable

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:
  Serialized Form

### Field Summary

Fields
`static ByteKey` `EMPTY` An empty key.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`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()` Returns `true` if the `byte[]` backing this `ByteKey` is of length 0.
`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()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### EMPTY

    public static final ByteKey EMPTY

An empty key.

### Method Detail

#### of

    public static ByteKey of(com.google.protobuf.ByteString value)

Creates a new `ByteKey` backed by the specified `ByteString`.

#### copyFrom

    public static ByteKey copyFrom(byte[] bytes)

Creates a new `ByteKey` backed by a copy of the specified `byte[]`.

Makes a copy of the underlying array.

#### of

    public static ByteKey of(int... bytes)

Creates a new `ByteKey` backed by a copy of the specified `int[]`. This method is primarily used as a convenience to create a `ByteKey` in code without casting down to signed Java `bytes`:

     ByteKey key = ByteKey.of(0xde, 0xad, 0xbe, 0xef);

Makes a copy of the input.

#### getValue

    public com.google.protobuf.ByteString getValue()

Returns an immutable `ByteString` representing this `ByteKey`.

Does not copy.

#### getBytes

    public byte[] getBytes()

Returns a newly-allocated `byte[]` representing this `ByteKey`.

Copies the underlying `byte[]`.

#### isEmpty

    public boolean isEmpty()

Returns `true` if the `byte[]` backing this `ByteKey` is of length 0.

#### compareTo

    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.

Specified by:
  `compareTo` in interface `Comparable<ByteKey>`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`