BinaryComparable (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.io, class: BinaryComparable

Package org.apache.hadoop.io

# Class BinaryComparable

java.lang.Object
org.apache.hadoop.io.BinaryComparable

All Implemented Interfaces:
  `Comparable<BinaryComparable>`

Direct Known Subclasses:
  `BytesWritable`, `Text`

@Public @Stable public abstract class BinaryComparable extends Object implements Comparable<BinaryComparable>
Interface supported by `WritableComparable` types supporting ordering/permutation by a representative set of bytes.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BinaryComparable()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(byte[] other, int off, int len)`
  Compare bytes from {#getBytes()} to those provided.
  `int`
  `compareTo(BinaryComparable other)`
  Compare bytes from {#getBytes()}.
  `boolean`
  `equals(Object other)`
  Return true if bytes from {#getBytes()} match.
  `abstract byte[]`
  `getBytes()`
  Return representative byte array for this instance.
  `abstract int`
  `getLength()`
  Return n st bytes 0..n-1 from {#getBytes()} are valid.
  `int`
  `hashCode()`
  Return a hash of the bytes returned from {#getBytes()}.

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

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

- ## Constructor Details

  - ### BinaryComparable

    public BinaryComparable()

- ## Method Details

  - ### getLength

    public abstract int getLength()
    Return n st bytes 0..n-1 from {#getBytes()} are valid.
    Returns:
      length.

  - ### getBytes

    public abstract byte[] getBytes()
    Return representative byte array for this instance.
    Returns:
      getBytes.

  - ### compareTo

    public int compareTo(BinaryComparable other)
    Compare bytes from {#getBytes()}.
    Specified by:
      `compareTo` in interface `Comparable<BinaryComparable>`
    See Also:
      - `WritableComparator.compareBytes(byte[],int,int,byte[],int,int)`

  - ### compareTo

    public int compareTo(byte[] other, int off, int len)
    Compare bytes from {#getBytes()} to those provided.
    Parameters:
      `other` - other.
      `off` - off.
      `len` - len.
    Returns:
      compareBytes.

  - ### equals

    public boolean equals(Object other)
    Return true if bytes from {#getBytes()} match.
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Return a hash of the bytes returned from {#getBytes()}.
    Overrides:
      `hashCode` in class `Object`
    See Also:
      - `WritableComparator.hashBytes(byte[],int)`