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

Package org.apache.hadoop.io

# Class MD5Hash

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

All Implemented Interfaces:
  `Comparable<MD5Hash>`, `Writable`, `WritableComparable<MD5Hash>`

@Public @Stable public class MD5Hash extends Object implements WritableComparable<MD5Hash>
A Writable for MD5 hash values.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `org.apache.hadoop.io.MD5Hash.Comparator`
  A WritableComparator optimized for MD5Hash keys.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `MD5_LEN`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MD5Hash()`
  Constructs an MD5Hash.
  `MD5Hash(byte[] digest)`
  Constructs an MD5Hash with a specified value.
  `MD5Hash(String hex)`
  Constructs an MD5Hash from a hex string.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(MD5Hash that)`
  Compares this object with the specified object for order.
  `static MD5Hash`
  `digest(byte[] data)`
  Construct a hash value for a byte array.
  `static MD5Hash`
  `digest(byte[][] dataArr, int start, int len)`
  Construct a hash value for an array of byte array.
  `static MD5Hash`
  `digest(byte[] data, int start, int len)`
  Construct a hash value for a byte array.
  `static MD5Hash`
  `digest(InputStream in)`
  Construct a hash value for the content from the InputStream.
  `static MD5Hash`
  `digest(String string)`
  Construct a hash value for a String.
  `static MD5Hash`
  `digest(org.apache.hadoop.io.UTF8 utf8)`
  Construct a hash value for a String.
  `boolean`
  `equals(Object o)`
  Returns true iff `o` is an MD5Hash whose digest contains the same values.
  `byte[]`
  `getDigest()`
  Returns the digest bytes.
  `static MessageDigest`
  `getDigester()`
  Create a thread local MD5 digester.
  `long`
  `halfDigest()`
  Construct a half-sized version of this MD5.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `int`
  `quarterDigest()`
  Return a 32-bit digest of the MD5.
  `static MD5Hash`
  `read(DataInput in)`
  Constructs, reads and returns an instance.
  `void`
  `readFields(DataInput in)`
  Deserialize the fields of this object from `in`.
  `void`
  `set(MD5Hash that)`
  Copy the contents of another instance into this instance.
  `void`
  `setDigest(String hex)`
  Sets the digest value from a hex string.
  `String`
  `toString()`
  Returns a string representation of this object.
  `void`
  `write(DataOutput out)`
  Serialize the fields of this object to `out`.

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

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

- ## Field Details

  - ### MD5_LEN

    public static final int MD5_LEN
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MD5Hash

    public MD5Hash()
    Constructs an MD5Hash.

  - ### MD5Hash

    public MD5Hash(String hex)
    Constructs an MD5Hash from a hex string.
    Parameters:
      `hex` - input hex.

  - ### MD5Hash

    public MD5Hash(byte[] digest)
    Constructs an MD5Hash with a specified value.
    Parameters:
      `digest` - digest.

- ## Method Details

  - ### readFields

    public void readFields(DataInput in) throws IOException
    Description copied from interface: `Writable`
    Deserialize the fields of this object from `in`.

    For efficiency, implementations should attempt to re-use storage in the existing object where possible.

    Specified by:
      `readFields` in interface `Writable`
    Parameters:
      `in` - `DataInput` to deseriablize this object from.
    Throws:
      `IOException` - any other problem for readFields.

  - ### read

    public static MD5Hash read(DataInput in) throws IOException
    Constructs, reads and returns an instance.
    Parameters:
      `in` - in.
    Returns:
      MD5Hash.
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### write

    public void write(DataOutput out) throws IOException
    Description copied from interface: `Writable`
    Serialize the fields of this object to `out`.
    Specified by:
      `write` in interface `Writable`
    Parameters:
      `out` - `DataOuput` to serialize this object into.
    Throws:
      `IOException` - any other problem for write.

  - ### set

    public void set(MD5Hash that)
    Copy the contents of another instance into this instance.
    Parameters:
      `that` - that.

  - ### getDigest

    public byte[] getDigest()
    Returns the digest bytes.
    Returns:
      digest.

  - ### digest

    public static MD5Hash digest(byte[] data)
    Construct a hash value for a byte array.
    Parameters:
      `data` - data.
    Returns:
      MD5Hash.

  - ### getDigester

    public static MessageDigest getDigester()
    Create a thread local MD5 digester.
    Returns:
      MessageDigest.

  - ### digest

    public static MD5Hash digest(InputStream in) throws IOException
    Construct a hash value for the content from the InputStream.
    Parameters:
      `in` - input stream.
    Returns:
      MD5Hash.
    Throws:
      `IOException` - raised on errors performing I/O.

  - ### digest

    public static MD5Hash digest(byte[] data, int start, int len)
    Construct a hash value for a byte array.
    Parameters:
      `data` - data.
      `start` - start.
      `len` - len.
    Returns:
      MD5Hash.

  - ### digest

    public static MD5Hash digest(byte[][] dataArr, int start, int len)
    Construct a hash value for an array of byte array.
    Parameters:
      `dataArr` - dataArr.
      `start` - start.
      `len` - len.
    Returns:
      MD5Hash.

  - ### digest

    public static MD5Hash digest(String string)
    Construct a hash value for a String.
    Parameters:
      `string` - string.
    Returns:
      MD5Hash.

  - ### digest

    public static MD5Hash digest(org.apache.hadoop.io.UTF8 utf8)
    Construct a hash value for a String.
    Parameters:
      `utf8` - utf8.
    Returns:
      MD5Hash.

  - ### halfDigest

    public long halfDigest()
    Construct a half-sized version of this MD5. Fits in a long.
    Returns:
      halfDigest.

  - ### quarterDigest

    public int quarterDigest()
    Return a 32-bit digest of the MD5.
    Returns:
      the first 4 bytes of the md5

  - ### equals

    public boolean equals(Object o)
    Returns true iff `o` is an MD5Hash whose digest contains the same values.
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Returns a hash code value for this object. Only uses the first 4 bytes, since md5s are evenly distributed.
    Overrides:
      `hashCode` in class `Object`

  - ### compareTo

    public int compareTo(MD5Hash that)
    Compares this object with the specified object for order.
    Specified by:
      `compareTo` in interface `Comparable<MD5Hash>`

  - ### toString

    public String toString()
    Returns a string representation of this object.
    Overrides:
      `toString` in class `Object`

  - ### setDigest

    public void setDigest(String hex)
    Sets the digest value from a hex string.
    Parameters:
      `hex` - hex.