ByteKey (Google Cloud Dataflow SDK 1.9.1 API)

Google Cloud Dataflow SDK for Java, version 1.9.1

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

Class 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 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>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object


Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Dataflow
Need help? Visit our support page.