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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcombineHashCode(int currentHashCode, int newHashCode) booleanprotected intfinalizeHashCode(int hashCode) protected intgetLongHashCode(long longValue) inthashCode()inthashCode(long address, long length) Calculates the hash code for a memory region.intCalculates 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:
hashCodein 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:
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.
-
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
-