LEND and Faster Algorithms for Constructing Minimal Perfect Hash Functions

Edward A. Fox, Qi Chen, Lenwood S. HeathVTechWorks 1992

Abstract

The Large External object-oriented Network Database (LEND) system has been developed to provide efficient access to large collections of primitive or multimedia objects, semantic networks, and information retrieval collections. A critical component of LEND's efficiency is its use of Minimal Perfect Hash Functions (MPHFs). This paper describes a novel three-stage algorithm—Mapping, Ordering, and Searching—for quickly finding MPHFs whose specification space is very close to the theoretical lower bound of approximately 2 bits per key. We present analytical and empirical results, including the successful processing of over 3.8 million keys in roughly six hours on a 1992-era workstation.

The Challenge of Large-Scale Indexing

In large-scale databases and information retrieval systems, retrieval speed is paramount. Standard hashing techniques are fast but suffer from collisions, where multiple keys map to the same location, necessitating slow resolution strategies. Perfect hashing eliminates collisions entirely, but often results in sparse, inefficient hash tables.

The ideal solution is a Minimal Perfect Hash Function (MPHF). As illustrated in Figure 2, an MPHF maps a set of $n$ keys to exactly $n$ slots with zero collisions and zero wasted space. Historically, finding such functions for millions of keys was computationally prohibitive or required excessive storage to describe the function itself. This research introduces "Algorithm 3," designed to build these functions rapidly while maintaining a compact memory footprint.

Minimal Perfect Hash Function (MPHF) mapping a key set S of size n to a hash table T of size n with no collisions.

The Three-Stage Algorithm

Algorithm 3 refines previous graph-based approaches into a streamlined pipeline:

1. Mapping

The $n$ keys are first partitioned into $b$ "buckets" using pseudo-random hash functions. The goal is to distribute keys such that approximately 60% of keys reside in 30% of the buckets, creating "dense" buckets that are prioritized during the construction phase. This partitioning, shown in Figure 6, uses functions like $h_{10}$ to distribute keys and $h_{11}, h_{12}$ to further refine the buckets.

The bucketing process using multiple hash functions (h10, h11, h12) to partition the key set into manageable buckets.

2. Ordering

Buckets are sorted by size in descending order. By processing the largest, most "constrained" buckets first, the algorithm solves the hardest parts of the puzzle while the hash table is still mostly empty. This significantly increases the probability of finding a fit for the remaining smaller buckets later.

3. Searching

For each bucket, the algorithm searches for a configuration—specifically a "rotation" value $g$—that allows all keys in that bucket to map to currently empty slots in the final hash table. Instead of complex re-hashing, the algorithm simply rotates the pattern of keys until they fit. Auxiliary data structures are used to track empty slots, allowing the search phase to jump directly to potential fits.

Key Results and Performance

The algorithm was validated using several large-scale datasets, most notably a library catalog record set from the OCLC containing 3,875,766 keys.

  • Efficiency: The algorithm successfully processed the 3.8 million keys using only 2.7 bits per key of specification space, nearing the theoretical lower bound.
  • Speed: On a NeXTstation (68040 processor), the 3.8M key set was processed in approximately 6 hours. For smaller sets (e.g., 4,000 keys), the construction is nearly instantaneous.
  • Scalability: The research highlights a direct space-time trade-off: while tighter functions (e.g., 2.4 bits/key) are possible, they require longer search times as the hash table becomes more crowded.

Conclusion

Algorithm 3 represents a significant advancement in the practical application of MPHFs for massive, static datasets. By combining a bucket-based mapping strategy with an efficient rotation heuristic, the system provides O(1) access time with minimal storage overhead. While currently limited to static key sets, future work may explore order-preserving functions to maintain sorted order within the hash table while retaining these performance gains.

Summary updated

Abstract

The Large External object-oriented Network Database (LEND) system has been developed to provide efficient access to large collections of primitive or multimedia objects, semantic networks, thesauri, hypertexts, and information retrieval collections. An overview of LEND is given, emphasizing aspects that yield efficient operation. In particular, a new algorithm is described for quickly finding minimal perfect hash functions whose specification space is very close to the theoretical lower bound, i.e., around 2 bits per key. The various stages of processing are detailed, along with analytical and empirical results, including timing for a set of over 3.8 million keys that was processed on a NeXTstation in about 6 hours.
BibTeX
@inproceedings{fox1992lend,
  author = {Edward A. Fox and Qi Chen and Lenwood S. Heath},
  title = {{LEND and Faster Algorithms for Constructing Minimal Perfect Hash Functions}},
  booktitle = {VTechWorks},
  year = {1992},
}
Figure