Class MurmurHasher
java.lang.Object
org.apache.arrow.memory.util.hash.MurmurHasher
- All Implemented Interfaces:
ArrowBufHasher
Implementation of the Murmur hashing algorithm. Details of the algorithm can be found in
https://en.wikipedia.org/wiki/MurmurHash
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 Summary
ConstructorDescriptionCreates a default Murmur hasher, with seed 0.MurmurHasher
(int seed) Creates a Murmur hasher. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
combineHashCode
(int currentHashCode, int intValue) Combine the current hash code and a new int value to calculate a new hash code.boolean
static int
finalizeHashCode
(int hashCode, long length) Finalizing the hash code.int
hashCode()
int
hashCode
(long address, long length) Calculates the hash code for a memory region.static int
hashCode
(long address, long length, int seed) Calculates the hash code for a memory region.int
Calculates the hash code for a memory region.static int
Calculates the hash code for a memory region.
-
Constructor Details
-
MurmurHasher
public MurmurHasher()Creates a default Murmur hasher, with seed 0. -
MurmurHasher
public MurmurHasher(int seed) Creates a Murmur hasher.- Parameters:
seed
- the seed for the hasher.
-
-
Method Details
-
hashCode
public int hashCode(long address, long length) Description copied from interface:ArrowBufHasher
Calculates the hash code for a memory region.- Specified by:
hashCode
in interfaceArrowBufHasher
- Parameters:
address
- start address of the memory region.length
- length of the memory region.- Returns:
- the hash code.
-
hashCode
Description copied from interface:ArrowBufHasher
Calculates the hash code for a memory region.- Specified by:
hashCode
in interfaceArrowBufHasher
- Parameters:
buf
- the buffer for the memory region.offset
- offset within the buffer for the memory region.length
- length of the memory region.- Returns:
- the hash code.
-
hashCode
Calculates the hash code for a memory region.- Parameters:
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.- Returns:
- the hash code.
-
hashCode
public static int hashCode(long address, long length, int seed) Calculates the hash code for a memory region.- Parameters:
address
- start address of the memory region.length
- length of the memory region.seed
- the seed.- Returns:
- the hash code.
-
combineHashCode
public static int combineHashCode(int currentHashCode, int intValue) Combine the current hash code and a new int value to calculate a new hash code.- Parameters:
currentHashCode
- the current hash code.intValue
- the new int value.- Returns:
- the new hah code.
-
finalizeHashCode
public static int finalizeHashCode(int hashCode, long length) Finalizing the hash code.- Parameters:
hashCode
- the current hash code.length
- the length of the memory region.- Returns:
- the finalized hash code.
-
equals
-
hashCode
public int hashCode()
-