public class MurmurHasher extends Object implements ArrowBufHasher
Murmur hashing is computationally expensive, as it involves several integer multiplications. However, the produced hash codes have good quality in the sense that they are uniformly distributed in the universe.
Therefore, this algorithm is suitable for scenarios where uniform hashing is desired (e.g. in an open addressing hash table/hash set).
| Constructor and Description |
|---|
MurmurHasher()
Creates a default Murmur hasher, with seed 0.
|
MurmurHasher(int seed)
Creates a Murmur hasher.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
combineHashCode(int currentHashCode,
int intValue)
Combine the current hash code and a new int value to calculate
a new hash code.
|
boolean |
equals(Object o) |
static int |
finalizeHashCode(int hashCode,
int length)
Finalizing the hash code.
|
int |
hashCode() |
int |
hashCode(ArrowBuf buf,
int offset,
int length)
Calculates the hash code for a memory region.
|
static int |
hashCode(ArrowBuf buf,
int offset,
int length,
int seed)
Calculates the hash code for a memory region.
|
int |
hashCode(long address,
int length)
Calculates the hash code for a memory region.
|
static int |
hashCode(long address,
int length,
int seed)
Calculates the hash code for a memory region.
|
public MurmurHasher()
public MurmurHasher(int seed)
seed - the seed for the hasher.public int hashCode(long address,
int length)
ArrowBufHasherhashCode in interface ArrowBufHasheraddress - start address of the memory region.length - length of the memory region.public int hashCode(ArrowBuf buf, int offset, int length)
ArrowBufHasherhashCode in interface ArrowBufHasherbuf - the buffer for the memory region.offset - offset within the buffer for the memory region.length - length of the memory region.public static int hashCode(ArrowBuf buf, int offset, int length, int seed)
buf - the buffer for the memory region.offset - offset within the buffer for the memory region.length - length of the memory region.seed - the seed.public static int hashCode(long address,
int length,
int seed)
address - start address of the memory region.length - length of the memory region.seed - the seed.public static int combineHashCode(int currentHashCode,
int intValue)
currentHashCode - the current hash code.intValue - the new int value.public static int finalizeHashCode(int hashCode,
int length)
hashCode - the current hash code.length - the length of the memory region.Copyright © 2019 The Apache Software Foundation. All rights reserved.