org.apache.lucene.util.hash
Class MurmurHash2

java.lang.Object
  extended by org.apache.lucene.util.hash.HashFunction
      extended by org.apache.lucene.util.hash.MurmurHash2
All Implemented Interfaces:
NamedSPILoader.NamedSPI

public class MurmurHash2
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 C version of MurmurHash 2.0 found at that site was ported to Java by Andrzej Bialecki (ab at getopt org).

The code from getopt.org was adapted by Mark Harwood in the form here as one of a pluggable choice of hashing functions as the core function had to be adapted to work with BytesRefs with offsets and lengths rather than raw byte arrays.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
static String HASH_NAME
           
 
Constructor Summary
MurmurHash2()
           
 
Method Summary
static int hash(byte[] data, int seed, int offset, int len)
           
 int hash(BytesRef br)
          Hashes the contents of the referenced bytes
static int hash32(byte[] data, int offset, int len)
          Generates 32 bit hash from byte array with default seed value.
 
Methods inherited from class org.apache.lucene.util.hash.HashFunction
availableHashFunctionNames, forName, getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HASH_NAME

public static final String HASH_NAME
See Also:
Constant Field Values
Constructor Detail

MurmurHash2

public MurmurHash2()
Method Detail

hash

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

hash32

public static final int hash32(byte[] data,
                               int offset,
                               int len)
Generates 32 bit hash from byte array with default seed value.

Parameters:
data - byte array to hash
offset - the start position in the array to hash
len - length of the array elements to hash
Returns:
32 bit hash of the given array

hash

public final int 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


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.