Package smile.hash

Class MurmurHash3

java.lang.Object
smile.hash.MurmurHash3

public class MurmurHash3 extends Object
MurmurHash is a very fast, non-cryptographic hash suitable for general hash-based lookup. The name comes from two basic operations, multiply (MU) and rotate (R), used in its inner loop. See this page for more details.

The current version is MurmurHash3, which yields a 32-bit or 128-bit hash value. When using 128-bits, the x86 and x64 versions do not produce the same values, as the algorithms are optimized for their respective platforms.

This class is adapted from Apache Cassandra.

  • Constructor Details

    • MurmurHash3

      public MurmurHash3()
  • Method Details

    • hash32

      public static int hash32(String text, int seed)
      32-bit MurmurHash3.
      Parameters:
      text - the text string.
      seed - the seed of hash code.
      Returns:
      the hash code.
    • hash32

      public static int hash32(byte[] data, int offset, int length, int seed)
      32-bit MurmurHash3.
      Parameters:
      data - the data buffer.
      offset - the start offset of data in the buffer.
      length - the length of data.
      seed - the seed of hash code.
      Returns:
      the hash code.
    • hash128

      public static void hash128(ByteBuffer data, int offset, int length, long seed, long[] result)
      128-bit MurmurHash3 for x64. When using 128-bits, the x86 and x64 versions do not produce the same values, as the algorithms are optimized for their respective platforms.
      Parameters:
      data - the data buffer.
      offset - the start offset of data in the buffer.
      length - the length of data.
      seed - the seed of hash code.
      result - the output of hash code.