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>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcomputeIndex(CharSequence key) Hashes akeyand computes an array index based on that hash.intcomputeIndexForHash(int hash) rangeForBucket(int index) Methods inherited from class org.hibernate.search.util.common.data.impl.HashTable
get, get, iterator, set, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
RangeHashTable
-
-
Method Details
-
computeIndex
Description copied from class:HashTableHashes akeyand computes an array index based on that hash.The maximum index is defined by constructor parameters passed to the hash function.
- Specified by:
computeIndexin classHashTable<T>- Parameters:
key- A key to hash in order to compute an index.- Returns:
- The index to use for the given
keyin a hash table of sizesize.
-
computeIndexForHash
public int computeIndexForHash(int hash) -
rangeForBucket
- Parameters:
index- An index between0andHashTable.size()(exclusive).- Returns:
- The range of
hashesassociated to the bucket for that index.
-