Class MurmurHash

java.lang.Object
cn.net.pap.common.datastructure.frequency.MurmurHash

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

The C version of MurmurHash 2.0 found at that site was ported to Java by Andrzej Bialecki (ab at getopt org).

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    hash(byte[] data)
     
    static int
    hash(byte[] data, int seed)
     
    static int
    hash(byte[] data, int length, int seed)
     
    static int
     
    static long
    hash64(byte[] data, int length)
    Generates 64 bit hash from byte array with default seed value.
    static long
    hash64(byte[] data, int length, int seed)
    Generates 64 bit hash from byte array of the given length and seed.
    static long
     
    static int
    hashLong(long data)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MurmurHash

      public MurmurHash()
  • Method Details

    • hash

      public static int hash(Object o)
    • hash

      public static int hash(byte[] data)
    • hash

      public static int hash(byte[] data, int seed)
    • hash

      public static int hash(byte[] data, int length, int seed)
    • hashLong

      public static int hashLong(long data)
    • hash64

      public static long hash64(Object o)
    • hash64

      public static long hash64(byte[] data, int length)
      Generates 64 bit hash from byte array with default seed value.
      Parameters:
      data - byte array to hash
      length - length of the array to hash
      Returns:
      64 bit hash of the given string
    • hash64

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