Class T1ha1

java.lang.Object
org.opensearch.common.hash.T1ha1

@InternalApi public final class T1ha1 extends Object
t1ha: Fast Positive Hash

Implements t1ha1; a fast portable hash function with reasonable quality for checksums, hash tables, and thin fingerprinting.

To overcome language and performance limitations, this implementation differs slightly from the reference implementation in C++, so the returned values may vary before JDK 18.

Intended for little-endian systems but returns the same result on big-endian, albeit marginally slower.

Opensearch.internal:
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    hash(byte[] input, int offset, int length)
    Returns the hash code for the specified range of the given byte array.
    static long
    hash(byte[] input, int offset, int length, long seed)
    Returns the hash code for the specified range of the given byte array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • hash

      public static long hash(byte[] input, int offset, int length)
      Returns the hash code for the specified range of the given byte array.
      Parameters:
      input - the input byte array
      offset - the starting offset
      length - the length of the range
      Returns:
      hash code
    • hash

      public static long hash(byte[] input, int offset, int length, long seed)
      Returns the hash code for the specified range of the given byte array.
      Parameters:
      input - the input byte array
      offset - the starting offset
      length - the length of the range
      seed - customized seed
      Returns:
      hash code