Class RangeHashTable<T>

java.lang.Object
org.hibernate.search.util.common.data.impl.HashTable<T>
org.hibernate.search.util.common.data.impl.RangeHashTable<T>
Type Parameters:
T - The type of elements stored in each bucket.
All Implemented Interfaces:
Iterable<T>

public final class RangeHashTable<T> extends HashTable<T>
A hash table that derives an index from hashes using a partition of the hashing space based on contiguous ranges.

This makes this table particularly suitable in situations where the hash must be computed before the number of buckets is known, then stored, then queried efficiently (e.g. retrieve all entries for a given bucket by querying WHERE hash BETWEEN bucketLowerBound AND bucketUpperBound). This wouldn't be as efficient with a modulo-based hash table such as ModuloHashTable, since the modulo operation would have to be applied to all entries at query time (it cannot be indexed since the number of buckets is not known when hashing).

  • Constructor Details

  • Method Details

    • computeIndex

      public int computeIndex(CharSequence key)
      Description copied from class: HashTable
      Hashes a key and computes an array index based on that hash.

      The maximum index is defined by constructor parameters passed to the hash function.

      Specified by:
      computeIndex in class HashTable<T>
      Parameters:
      key - A key to hash in order to compute an index.
      Returns:
      The index to use for the given key in a hash table of size size.
    • computeIndexForHash

      public int computeIndexForHash(int hash)
    • rangeForBucket

      public Range<Integer> rangeForBucket(int index)
      Parameters:
      index - An index between 0 and HashTable.size() (exclusive).
      Returns:
      The range of hashes associated to the bucket for that index.