Class SimpleHasher
java.lang.Object
org.apache.arrow.memory.util.hash.SimpleHasher
- All Implemented Interfaces:
ArrowBufHasher
A simple hasher that calculates the hash code of integers as is, and does not perform any
finalization. So the computation is extremely efficient.
This algorithm only provides the most basic semantics for the hash code. That is, if two objects are equal, they must have equal hash code. However, the quality of the produced hash code may not be good. In other words, the generated hash codes are far from being uniformly distributed in the universe.
Therefore, this algorithm is suitable only for scenarios where the most basic semantics of the hash code is required (e.g. in scenarios that require fast and proactive data pruning)
An object of this class is stateless, so it can be shared between threads.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
combineHashCode
(int currentHashCode, int newHashCode) boolean
protected int
finalizeHashCode
(int hashCode) protected int
getLongHashCode
(long longValue) int
hashCode()
int
hashCode
(long address, long length) Calculates the hash code for a memory region.int
Calculates the hash code for a memory region.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
SimpleHasher
protected SimpleHasher()
-
-
Method Details
-
hashCode
public int hashCode(long address, long length) 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
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.
-
combineHashCode
protected int combineHashCode(int currentHashCode, int newHashCode) -
getLongHashCode
protected int getLongHashCode(long longValue) -
finalizeHashCode
protected int finalizeHashCode(int hashCode) -
hashCode
public int hashCode() -
equals
-