Class MurmurHash3

java.lang.Object
org.infinispan.commons.hash.MurmurHash3
All Implemented Interfaces:
Hash

@ThreadSafe @Immutable public class MurmurHash3 extends Object implements Hash
MurmurHash3 implementation in Java, based on Austin Appleby's original in C Only implementing x64 version, because this should always be faster on 64 bit native processors, even 64 bit being ran with a 32 bit OS; this should also be as fast or faster than the x86 version on some modern 32 bit processors.
Since:
5.0
Author:
Patrick McFarland
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final byte
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object other)
     
     
    int
    hash(byte[] payload)
    Hashes a byte array efficiently.
    int
    hash(int hashcode)
    An incremental version of the hash function, that spreads a pre-calculated hash code, such as one derived from Object.hashCode().
    static int
    hash(long[] payload)
    Hashes a byte array efficiently.
    int
    A helper that calculates the hashcode of an object, choosing the optimal mechanism of hash calculation after considering the type of the object (byte array, String or Object).
    int
     
    static long[]
    MurmurHash3_x64_128(byte[] key, int seed)
    Hash a value using the x64 128 bit variant of MurmurHash3
    static long[]
    MurmurHash3_x64_128(long[] key, int seed)
    Hash a value using the x64 128 bit variant of MurmurHash3
    static int
    MurmurHash3_x64_32(byte[] key, int seed)
    Hash a value using the x64 32 bit variant of MurmurHash3
    static int
    MurmurHash3_x64_32(long[] key, int seed)
    Hash a value using the x64 32 bit variant of MurmurHash3
    static long
    MurmurHash3_x64_64(byte[] key, int seed)
    Hash a value using the x64 64 bit variant of MurmurHash3
    static long
    MurmurHash3_x64_64(long[] key, int seed)
    Hash a value using the x64 64 bit variant of MurmurHash3
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.infinispan.commons.hash.Hash

    maxHashBits
  • Field Details

  • Method Details

    • getInstance

      public static MurmurHash3 getInstance()
    • MurmurHash3_x64_128

      public static long[] MurmurHash3_x64_128(byte[] key, int seed)
      Hash a value using the x64 128 bit variant of MurmurHash3
      Parameters:
      key - value to hash
      seed - random value
      Returns:
      128 bit hashed key, in an array containing two longs
    • MurmurHash3_x64_64

      public static long MurmurHash3_x64_64(byte[] key, int seed)
      Hash a value using the x64 64 bit variant of MurmurHash3
      Parameters:
      key - value to hash
      seed - random value
      Returns:
      64 bit hashed key
    • MurmurHash3_x64_32

      public static int MurmurHash3_x64_32(byte[] key, int seed)
      Hash a value using the x64 32 bit variant of MurmurHash3
      Parameters:
      key - value to hash
      seed - random value
      Returns:
      32 bit hashed key
    • MurmurHash3_x64_128

      public static long[] MurmurHash3_x64_128(long[] key, int seed)
      Hash a value using the x64 128 bit variant of MurmurHash3
      Parameters:
      key - value to hash
      seed - random value
      Returns:
      128 bit hashed key, in an array containing two longs
    • MurmurHash3_x64_64

      public static long MurmurHash3_x64_64(long[] key, int seed)
      Hash a value using the x64 64 bit variant of MurmurHash3
      Parameters:
      key - value to hash
      seed - random value
      Returns:
      64 bit hashed key
    • MurmurHash3_x64_32

      public static int MurmurHash3_x64_32(long[] key, int seed)
      Hash a value using the x64 32 bit variant of MurmurHash3
      Parameters:
      key - value to hash
      seed - random value
      Returns:
      32 bit hashed key
    • hash

      public int hash(byte[] payload)
      Description copied from interface: Hash
      Hashes a byte array efficiently.
      Specified by:
      hash in interface Hash
      Parameters:
      payload - a byte array to hash
      Returns:
      a hash code for the byte array
    • hash

      public static int hash(long[] payload)
      Hashes a byte array efficiently.
      Parameters:
      payload - a byte array to hash
      Returns:
      a hash code for the byte array
    • hash

      public int hash(int hashcode)
      Description copied from interface: Hash
      An incremental version of the hash function, that spreads a pre-calculated hash code, such as one derived from Object.hashCode().
      Specified by:
      hash in interface Hash
      Parameters:
      hashcode - an object's hashcode
      Returns:
      a spread and hashed version of the hashcode
    • hash

      public int hash(Object o)
      Description copied from interface: Hash
      A helper that calculates the hashcode of an object, choosing the optimal mechanism of hash calculation after considering the type of the object (byte array, String or Object).
      Specified by:
      hash in interface Hash
      Parameters:
      o - object to hash
      Returns:
      a hashcode
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object