ShockHash:超越暴力搜索的渐进最优空间最小完美哈希
ShockHash: Towards Optimal-Space Minimal Perfect Hashing Beyond Brute-Force
AI总结:
ShockHash 利用布谷鸟哈希与伪森林图,将最小完美哈希的种子尝试次数从 e^n 降至 (e/2)^n,空间接近理论下界,比暴力搜索快近 2^n 倍。
摘要:
最小完美哈希函数(MPHF)将包含 $n$ 个键的集合 $S$ 无冲突地映射到前 $n$ 个整数。表示一个 MPHF 所需空间的下界为 $n\log_2e-O(\log n)$ 比特。通过暴力搜索算法(即随机尝试哈希函数直到偶然发现一个 MPHF,并存储该函数的种子)可获得匹配的上界。在期望情况下,需要测试 $e^n\textrm{poly}(n)$ 个种子。先前构建 MPHF 的空间效率最高的算法均使用此类暴力搜索方法作为基本构建块。\n 在本文中,我们引入 ShockHash——小型、高度过载的布谷鸟哈希表。ShockHash 使用两个哈希函数 $h_0$ 和 $h_1$,期望存在一个函数 $f : S \rightarrow \{0,1\}$ 使得 $x \mapsto h_{f(x)}(x)$ 是 $S$ 上的 MPHF。用图论术语来说,ShockHash 生成 $n$ 条边的随机图,直到偶然发现一个伪森林——即每个连通分量中边数与节点数相等的图。利用布谷鸟哈希,ShockHash 随后在线性时间内从伪森林推导出 MPHF。它使用一个 1 比特检索数据结构,以 $n + o(n)$ 比特存储 $f$。\n 通过仔细分析随机图为伪森林的概率,我们证明 ShockHash 在期望情况下仅需尝试 $(e/2)^n\textrm{poly}(n)$ 个哈希函数种子,从而将存储种子的空间减少约 $n$ 比特。这使得 ShockHash 比暴力搜索快近 $2^n$ 倍,同时保持渐进最优的空间消耗。在 RecSplit 框架内的实现产生了当前空间效率最高的 MPHF,即竞争方法需要多约两个数量级的工作量才能达到相同的空间。
英文摘要:
A minimal perfect hash function (MPHF) maps a set $S$ of $n$ keys to the first $n$ integers without collisions. There is a lower bound of $n\log_2e-O(\log n)$ bits of space needed to represent an MPHF. A matching upper bound is obtained using the brute-force algorithm that tries random hash functions until stumbling on an MPHF and stores that function's seed. In expectation, $e^n\textrm{poly}(n)$ seeds need to be tested. The most space-efficient previous algorithms for constructing MPHFs all use such a brute-force approach as a basic building block. In this paper, we introduce ShockHash - Small, heavily overloaded cuckoo hash tables. ShockHash uses two hash functions $h_0$ and $h_1$, hoping for the existence of a function $f : S \rightarrow \{0,1\}$ such that $x \mapsto h_{f(x)}(x)$ is an MPHF on $S$. In graph terminology, ShockHash generates $n$-edge random graphs until stumbling on a pseudoforest - a graph where each component contains as many edges as nodes. Using cuckoo hashing, ShockHash then derives an MPHF from the pseudoforest in linear time. It uses a 1-bit retrieval data structure to store $f$ using $n + o(n)$ bits. By carefully analyzing the probability that a random graph is a pseudoforest, we show that ShockHash needs to try only $(e/2)^n\textrm{poly}(n)$ hash function seeds in expectation, reducing the space for storing the seed by roughly $n$ bits. This makes ShockHash almost a factor $2^n$ faster than brute-force, while maintaining the asymptotically optimal space consumption. An implementation within the RecSplit framework yields the currently most space efficient MPHFs, i.e., competing approaches need about two orders of magnitude more work to achieve the same space.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。