Class SimpleHasher

java.lang.Object
org.apache.arrow.memory.util.hash.SimpleHasher
All Implemented Interfaces:
ArrowBufHasher

public class SimpleHasher extends Object implements 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 Details

  • 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 interface ArrowBufHasher
      Parameters:
      address - start address of the memory region.
      length - length of the memory region.
      Returns:
      the hash code.
    • hashCode

      public int hashCode(ArrowBuf buf, long offset, long length)
      Calculates the hash code for a memory region.
      Specified by:
      hashCode in interface ArrowBufHasher
      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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object