Class MurmurHash64


  • public class MurmurHash64
    extends HashFunction
    This is a very fast, non-cryptographic hash suitable for general hash-based lookup. See http://murmurhash.googlepages.com/ for more details.

    The code from Apache Commons was adapted in the form here to work with BytesRefs with offsets and lengths rather than raw byte arrays.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static HashFunction INSTANCE  
      private static long M64  
      private static int R64  
    • Constructor Summary

      Constructors 
      Constructor Description
      MurmurHash64()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long hash​(BytesRef br)
      Hashes the contents of the referenced bytes
      static long hash64​(byte[] data, int seed, int offset, int length)
      Generates a 64-bit hash from byte array of the given length and seed.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MurmurHash64

        public MurmurHash64()
    • Method Detail

      • hash64

        public static long hash64​(byte[] data,
                                  int seed,
                                  int offset,
                                  int length)
        Generates a 64-bit hash from byte array of the given length and seed.
        Parameters:
        data - The input byte array
        seed - The initial seed value
        length - The length of the array
        Returns:
        The 64-bit hash of the given array
      • hash

        public final long hash​(BytesRef br)
        Description copied from class: HashFunction
        Hashes the contents of the referenced bytes
        Specified by:
        hash in class HashFunction
        Parameters:
        br - the data to be hashed
        Returns:
        the hash of the bytes referenced by bytes.offset and length bytes.length
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object