Rank and select data structures seek to preprocess a bit vector to quickly answer two kinds of queries: rank(i) gives the number of 1 bits in slots 0 through i, and select(j) gives the first slot s with rank(s) = j. A succinct data structure can answer these queries while using space much smaller than the size of the original bit vector. State of the art succinct rank and select data structures use as little as 4% extra space while answering rank and select queries quickly. Rank queries can be answered using only a handful of array accesses. Select queries can be answered by starting with similar array accesses, followed by a linear scan. Despite these strong results, a tradeoff remains: data structures that use under 4% space are significantly slower at answering rank and select queries than less-space-efficient data structures (using, say, > 20% extra space). In this paper we make significant progress towards closing this gap. We give a new data structure, SPIDER, which uses 3.82% extra space. SPIDER gives the best rank query time for data sets of 8 billion or more bits, even compared to less space-efficient data structures. For select queries, SPIDER outperforms all data structures that use less than 4% space, and significantly closes the gap in select performance between data structures with less than 4% space, and those that use more (over 20%) space. SPIDER makes two main technical contributions. For rank queries, it improves performance by interleaving the metadata with the bit vector to improve cache efficiency. For select queries, it uses predictions to almost eliminate the cost of the linear scan. These predictions are inspired by recent results on data structures with machine-learned predictions, adapted to the succinct data structure setting. Our results hold on both real and synthetic data, showing that these predictions are effective in practice.
翻译:摘要:排名与选择数据结构旨在预处理一个位向量,以快速回答两类查询:rank(i)给出插槽0到i中1比特的数量,select(j)给出满足rank(s)=j的第一个插槽s。简洁数据结构能在远小于原始位向量大小的存储空间下回答这些查询。当前最先进的简洁排名与选择数据结构仅使用4%的额外空间,即可快速回答排名与选择查询。排名查询仅需少量数组访问即可完成。选择查询可通过类似的数组访问后接线性扫描来回答。尽管取得了这些显著成果,但仍存在权衡:使用低于4%空间的数据结构在回答排名与选择查询时的速度明显慢于空间效率较低的数据结构(例如使用超过20%的额外空间)。本文在弥合这一差距方面取得了重要进展。我们提出了一种名为SPIDER的新数据结构,仅占用3.82%的额外空间。即使与空间效率更低的数据结构相比,SPIDER在80亿比特或更大数据集的排名查询时间上表现最佳。对于选择查询,SPIDER优于所有使用低于4%空间的数据结构,并显著缩小了使用低于4%空间的数据结构与使用更多空间(超过20%)的数据结构在选择性能上的差距。SPIDER做出了两个主要技术贡献。对于排名查询,它通过将元数据与位向量交错存储以提升缓存效率,从而改善性能。对于选择查询,它使用预测技术几乎消除了线性扫描的开销。这些预测方法受近期关于带机器学习预测的数据结构研究启发,并针对简洁数据结构场景进行了适配。我们的结果在真实数据和合成数据上均成立,表明这些预测在实践中是有效的。