org.apache.commons.codec.digest

## Class MurmurHash3

- java.lang.Object
- - org.apache.commons.codec.digest.MurmurHash3

-     public final class MurmurHash3
      extends Object

  MurmurHash3 yields a 32-bit or 128-bit value. MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup. The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop. Unlike cryptographic hash functions, it is not specifically designed to be difficult to reverse by an adversary, making it unsuitable for cryptographic purposes. 32-bit Java port of https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp#94 128-bit Java port of https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp#255 This is a public domain code with no copyrights. From homepage of MurmurHash (https://code.google.com/p/smhasher/), "All MurmurHash versions are public domain software, and the author disclaims all copyright to their code." Copied from Apache Hive: https://github.com/apache/hive/blob/master/storage-api/src/java/org/apache/hive/common/util/Murmur3.java
  Since:
    1.13
  See Also:
    MurmurHash

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `MurmurHash3.IncrementalHash32`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_SEED`
    `static long` | `NULL_HASHCODE`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static long[]` | `hash128(byte[] data)` Murmur3 128-bit variant.
    `static long[]` | `hash128(byte[] data, int offset, int length, int seed)` Murmur3 128-bit variant.
    `static long[]` | `hash128(String data)` Murmur3 128-bit variant.
    `static int` | `hash32(byte[] data)` Generates 32 bit hash from byte array with the default seed.
    `static int` | `hash32(byte[] data, int length)` Generates 32 bit hash from byte array with the default seed.
    `static int` | `hash32(byte[] data, int length, int seed)` Generates 32 bit hash from byte array with the given length and seed.
    `static int` | `hash32(byte[] data, int offset, int length, int seed)` Generates 32 bit hash from byte array with the given length, offset and seed.
    `static int` | `hash32(long l0)` Generates 32 bit hash from a long with default seed value.
    `static int` | `hash32(long l0, int seed)` Generates 32 bit hash from a long with the given seed.
    `static int` | `hash32(long l0, long l1)` Generates 32 bit hash from two longs with default seed value.
    `static int` | `hash32(long l0, long l1, int seed)` Generates 32 bit hash from two longs with the given seed.
    `static int` | `hash32(String data)` Generates 32 bit hash from a string with the default seed.
    `static long` | `hash64(byte[] data)` Murmur3 64-bit variant.
    `static long` | `hash64(byte[] data, int offset, int length)` Generates 64 bit hash from byte array with the given length, offset and default seed.
    `static long` | `hash64(byte[] data, int offset, int length, int seed)` Generates 64 bit hash from byte array with the given length, offset and seed.
    `static long` | `hash64(int data)` Murmur3 64-bit variant.
    `static long` | `hash64(long data)` Murmur3 64-bit variant.
    `static long` | `hash64(short data)` Murmur3 64-bit variant.

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

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

- - ### Field Detail

    - #### NULL_HASHCODE

          public static final long NULL_HASHCODE

      See Also:
        Constant Field Values

    - #### DEFAULT_SEED

          public static final int DEFAULT_SEED

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### hash32

          public static int hash32(long l0,
                                   long l1)

      Generates 32 bit hash from two longs with default seed value.
      Parameters:
        `l0` - long to hash
        `l1` - long to hash
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(long l0)

      Generates 32 bit hash from a long with default seed value.
      Parameters:
        `l0` - long to hash
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(long l0,
                                   int seed)

      Generates 32 bit hash from a long with the given seed.
      Parameters:
        `l0` - long to hash
        `seed` - initial seed value
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(long l0,
                                   long l1,
                                   int seed)

      Generates 32 bit hash from two longs with the given seed.
      Parameters:
        `l0` - long to hash
        `l1` - long to hash
        `seed` - initial seed value
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(byte[] data)

      Generates 32 bit hash from byte array with the default seed.
      Parameters:
        `data` - - input byte array
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(String data)

      Generates 32 bit hash from a string with the default seed.
      Parameters:
        `data` - - input string
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(byte[] data,
                                   int length)

      Generates 32 bit hash from byte array with the default seed.
      Parameters:
        `data` - - input byte array
        `length` - - length of array
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(byte[] data,
                                   int length,
                                   int seed)

      Generates 32 bit hash from byte array with the given length and seed.
      Parameters:
        `data` - - input byte array
        `length` - - length of array
        `seed` - - seed. (default 0)
      Returns:
        32 bit hash

    - #### hash32

          public static int hash32(byte[] data,
                                   int offset,
                                   int length,
                                   int seed)

      Generates 32 bit hash from byte array with the given length, offset and seed.
      Parameters:
        `data` - - input byte array
        `offset` - - offset of data
        `length` - - length of array
        `seed` - - seed. (default 0)
      Returns:
        32 bit hash

    - #### hash64

          public static long hash64(byte[] data)

      Murmur3 64-bit variant. This is essentially MSB 8 bytes of Murmur3 128-bit variant.
      Parameters:
        `data` - - input byte array
      Returns:
        64 bit hash

    - #### hash64

          public static long hash64(long data)

      Murmur3 64-bit variant. This is essentially MSB 8 bytes of Murmur3 128-bit variant.
      Parameters:
        `data` - - input long
      Returns:
        64 bit hash

    - #### hash64

          public static long hash64(int data)

      Murmur3 64-bit variant. This is essentially MSB 8 bytes of Murmur3 128-bit variant.
      Parameters:
        `data` - - input int
      Returns:
        64 bit hash

    - #### hash64

          public static long hash64(short data)

      Murmur3 64-bit variant. This is essentially MSB 8 bytes of Murmur3 128-bit variant.
      Parameters:
        `data` - - input short
      Returns:
        64 bit hash

    - #### hash64

          public static long hash64(byte[] data,
                                    int offset,
                                    int length)

      Generates 64 bit hash from byte array with the given length, offset and default seed.
      Parameters:
        `data` - - input byte array
        `offset` - - offset of data
        `length` - - length of array
      Returns:
        64 bit hash

    - #### hash64

          public static long hash64(byte[] data,
                                    int offset,
                                    int length,
                                    int seed)

      Generates 64 bit hash from byte array with the given length, offset and seed.
      Parameters:
        `data` - - input byte array
        `offset` - - offset of data
        `length` - - length of array
        `seed` - - seed. (default 0)
      Returns:
        64 bit hash

    - #### hash128

          public static long[] hash128(byte[] data)

      Murmur3 128-bit variant.
      Parameters:
        `data` - - input byte array
      Returns:
        - 128 bit hash (2 longs)

    - #### hash128

          public static long[] hash128(String data)

      Murmur3 128-bit variant.
      Parameters:
        `data` - - input String
      Returns:
        - 128 bit hash (2 longs)

    - #### hash128

          public static long[] hash128(byte[] data,
                                       int offset,
                                       int length,
                                       int seed)

      Murmur3 128-bit variant.
      Parameters:
        `data` - - input byte array
        `offset` - - the first element of array
        `length` - - length of array
        `seed` - - seed. (default is 0)
      Returns:
        - 128 bit hash (2 longs)

Copyright © 2002–2019 The Apache Software Foundation. All rights reserved.