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
ConstructorsConstructorDescriptionCreates a default Murmur hasher, with seed 0.MurmurHasher(int seed) Creates a Murmur hasher. -
Method Summary
Modifier and TypeMethodDescriptionstatic intcombineHashCode(int currentHashCode, int intValue) Combine the current hash code and a new int value to calculate a new hash code.booleanstatic intfinalizeHashCode(int hashCode, long length) Finalizing the hash code.inthashCode()inthashCode(long address, long length) Calculates the hash code for a memory region.static inthashCode(long address, long length, int seed) Calculates the hash code for a memory region.intCalculates the hash code for a memory region.static intCalculates 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:ArrowBufHasherCalculates the hash code for a memory region.- Specified by:
hashCodein interfaceArrowBufHasher- Parameters:
address- start address of the memory region.length- length of the memory region.- Returns:
- the hash code.
-
hashCode
Description copied from interface:ArrowBufHasherCalculates the hash code for a memory region.- Specified by:
hashCodein 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()
-