Package smile.hash

Interface MurmurHash3


public interface MurmurHash3
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.

  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static void
    hash128(ByteBuffer data, int offset, int length, long seed, long[] result)
    128-bit MurmurHash3 for x64.
    static int
    hash32(byte[] data, int offset, int length, int seed)
    32-bit MurmurHash3.
    static int
    hash32(String text, int seed)
    32-bit MurmurHash3.
  • Method Details

    • hash32

      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

      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

      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.