ShockHash:超越暴力搜索的近最优空间最小完美哈希
ShockHash: Near Optimal-Space Minimal Perfect Hashing Beyond Brute-Force
AI总结:
本文提出 ShockHash,利用高度过载布谷鸟哈希表与伪森林结构,以近最优空间和远低于暴力搜索的代价构造 MPHF,并在 RecSplit 等框架中实现显著加速。
摘要:
最小完美哈希函数(MPHF)将包含 n 个键的集合 S 无冲突地映射到前 n 个整数。表示一个 MPHF 存在 n·log(e)=1.44n 位的下界。暴力算法期望尝试 e^n 个哈希函数种子,并存储第一个产生 MPHF 的种子,即可达到该下界。以往空间效率最高的 MPHF 构造算法都将这种暴力方法作为基本构建块。\n\n本文提出 ShockHash——用于最小完美哈希的小型、高度过载布谷鸟哈希表。ShockHash 使用两个哈希函数 h_0 和 h_1,期望存在函数 f: S→{0,1},使 x→h_{f(x)}(x) 成为 S 上的 MPHF。随后它使用 1 位检索数据结构,以 n+o(n) 位存储 f。\n\n用图论术语来说,ShockHash 生成 n 条边的随机图,直到偶然发现一个伪森林——其中每个连通分量的边数与节点数相等。然后,ShockHash 利用布谷鸟哈希在线性时间内从该伪森林导出 MPHF。我们证明,ShockHash 期望只需尝试约 (e/2)^n=1.359^n 个种子。这使存储种子所需空间减少约 n 位(同时保持渐近最优的空间消耗),并且与暴力方法相比,构造速度几乎提升 2^n 倍。二分图 ShockHash 通过维护候选哈希函数池并检查所有可能的配对,将期望构造时间进一步降至 1.166^n。\n\n将 ShockHash 作为 RecSplit 框架中的构建块,其构造速度最高可比竞争方法快 3 个数量级。它能在约半小时内为 1000 万个键构建每个键仅需 1.489 位的 MPHF。而在高效的 k-perfect 哈希函数之后使用 ShockHash 时,其空间占用与最佳竞争方法相近,同时构造和查询速度显著更快。
英文摘要:
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(e)=1.44n bits needed to represent an MPHF. This can be reached by a brute-force algorithm that tries e^n hash function seeds in expectation and stores the first seed leading to an MPHF. 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 for minimal perfect hashing. ShockHash uses two hash functions h_0 and h_1, hoping for the existence of a function f : S->{0, 1} such that x -> h_{f(x)}(x) is an MPHF on S. It then uses a 1-bit retrieval data structure to store f using n + o(n) bits. In graph terminology, ShockHash generates n-edge random graphs until stumbling on a pseudoforest - where each component contains as many edges as nodes. Using cuckoo hashing, ShockHash then derives an MPHF from the pseudoforest in linear time. We show that ShockHash needs to try only about (e/2)^n=1.359^n seeds in expectation. This reduces the space for storing the seed by roughly n bits (maintaining the asymptotically optimal space consumption) and speeds up construction by almost a factor of 2^n compared to brute-force. Bipartite ShockHash reduces the expected construction time again to 1.166^n by maintaining a pool of candidate hash functions and checking all possible pairs. ShockHash as a building block within the RecSplit framework can be constructed up to 3 orders of magnitude faster than competing approaches. It can build an MPHF for 10 million keys with 1.489 bits per key in about half an hour. When instead using ShockHash after an efficient k-perfect hash function, it achieves space usage similar to the best competitors, while being significantly faster to construct and query.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。