ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
FMIndex.h File Reference

The FM-index of Ferragina and Manzini (chapter 14, Block-Sorting Compression, of Ferragina's book, beyond the book of Montresor): the transform of Burrows and Wheeler of \( s \) [see BurrowsWheeler.h] as an index of its substrings, which replaces the suffix array and the text. More...

#include "ADS/Contract.h"
#include "ADS/compression/BurrowsWheeler.h"
#include "ADS/succinct/RankSelect.h"
#include <algorithm>
#include <array>
#include <bit>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "ADS/compression/impl/FMIndex.tpp"

Go to the source code of this file.

Classes

class  ADS::FMIndex
 the FM-index of a text: its transform with the counts for the rank every \( b \) places and the places of the suffixes at the multiples of \( \mu \) More...

Namespaces

namespace  ADS

Detailed description

The FM-index of Ferragina and Manzini (chapter 14, Block-Sorting Compression, of Ferragina's book, beyond the book of Montresor): the transform of Burrows and Wheeler of \( s \) [see BurrowsWheeler.h] as an index of its substrings, which replaces the suffix array and the text.

  • count( P ) is the backward search: the rows of \( M' \) prefixed by \( P[ i , p - 1 ] \) are a range \( [ \mathit{first} , \mathit{last} ) \), and those prefixed by \( c P[ i , p - 1 ] \), with \( c = P[ i - 1 ] \), are \( [ C[ c ] + \mathrm{rank}_c( \mathit{first} ) , C[ c ] + \mathrm{rank}_c( \mathit{last} ) ) \), the LF-mapping of the first and of the last occurrence of \( c \) in \( L[ \mathit{first} , \mathit{last} ) \); hence \( p \) steps, each of two ranks, give the range of \( P \) and its number of occurrences, \( \mathit{last} - \mathit{first} \), with no access to the text;
  • locate( P ) finds the place of each row of the range: the rows of the suffixes that start at a multiple of \( \mu \) are marked, with their places, and from any row the LF-mapping, which moves one symbol to the left in \( s \), reaches a marked row in \( t < \mu \) steps, the place being that of the marked row plus \( t \); this gives \( O( \mu ) \) steps per occurrence and \( O( ( n / \mu ) \log n ) \) bits of samples;
  • extract( i , j ) gives \( s[ i , j ) \) from the row of the first sampled suffix at or after \( j \), by \( j - i + O( \mu ) \) steps of the LF-mapping.

The rank of a symbol in \( L \), the number of its occurrences in a prefix, is the count stored every \( b \) places for each symbol of the text plus a scan of fewer than \( b \) symbols, 8 at a time by the zero bytes of a word, i.e., \( O( b ) \) time and \( \sigma ( n / b ) \) counts of 32 bits; the marks of the rows are a vector of bits with the rank directory of RankSelect [see RankSelect.h], so that a row is tested and its sample found in \( O( 1 ) \) time. The counts of \( L \) are the simplest rank on a sequence, which any structure of rank and select on sequences can replace [see WaveletMatrix.h]: the wavelet tree of Grossi, Gupta and Vitter gives the rank in \( O( \log \sigma ) \) time on \( n H_0 + o( n \log \sigma ) \) bits, and the compressed representations of Ferragina, Manzini, Mäkinen and Navarro reach \( n H_k + o( n \log \sigma ) \) bits, the space of the compressed text. The transform is built from the suffix array of SA-IS, in \( O( n ) \) time [see BurrowsWheeler.h]. Against the suffix array, which counts by binary search in \( O( p \log n ) \) time on \( n \log n \) bits plus the text, the FM-index counts in \( O( p b ) \) time here, \( O( p ) \) with a rank in \( O( 1 ) \), at the price of random accesses to \( L \) at each step; the r-index of Gagie, Navarro and Prezza samples only the ends of the runs of \( L \), and takes space proportional to their number \( r \), small on repetitive texts [see RIndex.h].

The contracts [see Contract.h]: \( b \) and \( \mu \) are positive, \( n < 2^{32} \), a pattern is not empty, \( i \le j \le n \); each place found by locate() is an occurrence, an audit. The operations are defined in FMIndex.tpp.

See also
P. Ferragina, Pearls of Algorithm Engineering, Cambridge University Press, 2023, chapter 14, Block-Sorting Compression, doi:10.1017/9781009128933
P. Ferragina, G. Manzini, Opportunistic data structures with applications, IEEE Symposium on Foundations of Computer Science, 390-398, 2000, doi:10.1109/SFCS.2000.892127
P. Ferragina, G. Manzini, Indexing compressed text, Journal of the ACM 52(4), 552-581, 2005, doi:10.1145/1082036.1082039
R. Grossi, A. Gupta, J. S. Vitter, High-order entropy-compressed text indexes, ACM-SIAM Symposium on Discrete Algorithms, 841-850, 2003
P. Ferragina, G. Manzini, V. Mäkinen, G. Navarro, Compressed representations of sequences and full-text indexes, ACM Transactions on Algorithms 3(2), 20, 2007, doi:10.1145/1240233.1240243
G. Navarro, V. Mäkinen, Compressed full-text indexes, ACM Computing Surveys 39(1), 2, 2007, doi:10.1145/1216370.1216372
T. Gagie, G. Navarro, N. Prezza, Fully functional suffix trees and optimal text searching in BWT-runs bounded space, Journal of the ACM 67(1), 2, 2020, doi:10.1145/3375890
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa