Text Indexing for Long Patterns using Locally Consistent Anchors

Lorraine A. K. Ayad, Grigorios Loukides, Solon P. PissisarXiv 2024

This paper, recently presented at a major conference, introduces a breakthrough in text indexing for "long patterns." By leveraging a new sampling technique called Randomized Reduced Bidirectional Anchors (rrBDA), the authors have developed a data structure that breaks the traditional trade-offs between index size, query speed, and construction efficiency.

TL;DR

The authors present a new text index that achieves "the best of all worlds" for long pattern queries. By assuming a minimum query length $\ell$, their randomized anchor-based index is significantly smaller and faster to query than classic structures like suffix arrays and FM-indexes, while also being much faster to build.

What Problem Does This Paper Address?

Text indexing is a foundational problem in computer science: how do you preprocess a massive text (like the human genome) so you can instantly find any pattern within it? Ideally, an index should be:

  1. Small: Low storage footprint.
  2. Fast to query: Near-instant results.
  3. Fast to build: Efficient preprocessing.
  4. Low memory during build: Doesn't crash your server while being created.

Classic indexes usually force you to pick two or three. Suffix arrays are lightning-fast but huge. Compressed indexes like the FM-index are tiny but can be orders of magnitude slower. This paper targets the "long pattern" regime—where we know query patterns will be at least $\ell$ characters long. This is common in bioinformatics (DNA sequencing reads) and natural language processing (long phrases or document deduplication).

Methods

The core innovation is the Randomized Reduced Bidirectional Anchor (rrBDA).

  • Locally Consistent Sampling: Instead of indexing every position in the text, the authors sample "anchors." These are chosen such that if two substrings are identical, they are guaranteed to have the same sampled anchor positions.
  • Randomization via Hashing: Previous "bidirectional anchors" used lexicographical (alphabetical) order to pick points, which often led to uneven sampling. This paper introduces Karp-Rabin fingerprints (randomized hashing) to select anchors, which spreads them more uniformly and reduces the overall index size.
  • Average-Case Linear Time Construction: The authors designed a novel algorithm that uses "minimizers" as a pre-filter and Longest Common Extension (LCE) queries to compute these anchors in $O(n)$ time on average.
  • Small-Space Implementation: They developed internal and semi-external memory versions that keep the peak memory usage during construction very close to the final index size, preventing the "memory explosion" often seen when building large suffix trees.
The rrBDA index structure and query process. (a) shows the two tries and the 2D grid. (b) illustrates a query for 'acaaa' being split and searched.

Datasets

The approach was evaluated on:

  • Pizza&Chili Corpus: Standard datasets including DNA, PROTEINS, XML, SOURCES, and ENGLISH.
  • HUMAN: The full human genome (~3.1 billion characters), a massive real-world test case.

Key Insights and Ideas

  • The "Long Pattern" Advantage: If you know your queries are at least $\ell$ characters long, you don't need to index everything. You only need to ensure that every window of length $\ell$ contains at least one anchor.
  • Randomization for Density: Using random hashes instead of alphabetical order to pick anchors reduces "anchor density" by up to 46%. Lower density directly translates to a smaller index and faster construction.
  • Hybrid Tie-Breaking: Bidirectional anchors are tricky because they "wrap around" fragments. The authors solved this by hashing a prefix of a rotation and using lexicographical rank for the remainder, combining the benefits of randomization with the stability of sorted order.
  • Theoretical Robustness: While the practical index has average-case guarantees, the authors also proved a version (Theorem 4) with worst-case guarantees using a concept called "partitioning sets," showing that this "best of all worlds" performance is theoretically possible even for adversarial data.

Key Results

  • Massive Space Savings: For a minimum pattern length $\ell=1024$, the rrBDA index is $5\times$ smaller than the FM-index and roughly $100\times$ smaller than a standard suffix array.
  • Superior Query Speed: It is 27% faster than a suffix array (the fastest classic competitor) and over $72\times$ faster than the FM-index on the human genome.
  • Scalability: On the full human genome, the index occupies just 11MB (for $\ell=2^{14}$), yet it answers queries significantly faster than a 1GB FM-index.
  • Construction Efficiency: Their new anchor computation algorithm is two orders of magnitude faster than previous simple implementations.

Limitations and Future Work

  • Minimum Length Constraint: This is a specialized index. It cannot answer queries shorter than the chosen $\ell$. It is meant to complement, not necessarily replace, general-purpose indexes.
  • Randomization: The construction is randomized (correct with high probability). While hash collisions are statistically negligible, creating a deterministic version with the same performance remains an open challenge.
  • Implementation Complexity: The version with worst-case guarantees is described as "extremely intricate" and has not yet been implemented or optimized for practical use.

Summary updated

BibTeX
@misc{ayad2024text,
  author = {Lorraine A. K. Ayad and Grigorios Loukides and Solon P. Pissis},
  title = {{Text Indexing for Long Patterns using Locally Consistent Anchors}},
  year = {2024},
  eprint = {2407.11819},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.11819},
}
Figure