Added RLCSA index option
[SXSI/TextCollection.git] / FMIndex.cpp
index 297604b..1127c6c 100644 (file)
@@ -57,9 +57,11 @@ FMIndex::FMIndex(uchar * bwt, ulong length, unsigned samplerate_,
 {
     makewavelet(bwt); // Deletes bwt!
     bwt = 0;
+
+    CSA::DeltaVector::Iterator notIndexedIt(notIndexed);
  
     // Make sampling tables
-    maketables(numberOfSamples_, tsType, notIndexed, niText);
+    maketables(numberOfSamples_, tsType, notIndexedIt, niText);
 }
 
 bool FMIndex::EmptyText(DocId k) const
@@ -1055,7 +1057,7 @@ void FMIndex::makewavelet(uchar *bwt)
 #endif
 }
 
-void FMIndex::maketables(ulong sampleLength, char tsType, CSA::DeltaVector & notIndexed, const string & niText)
+void FMIndex::maketables(ulong sampleLength, char tsType, CSA::DeltaVector::Iterator & notIndexedIt, const string & niText)
 {
     // Calculate BWT end-marker position (of last inserted text)
     {
@@ -1131,7 +1133,7 @@ void FMIndex::maketables(ulong sampleLength, char tsType, CSA::DeltaVector & not
             if (prevTextId == numberOfTexts)
             {
                 prevTextId = 0;
-                while (notIndexed.isSet(prevTextId))
+                while (notIndexedIt.isSet(prevTextId))
                     ++ prevTextId;
                 // Now prevTextId points to the first indexed Doc ID.
             }
@@ -1139,7 +1141,7 @@ void FMIndex::maketables(ulong sampleLength, char tsType, CSA::DeltaVector & not
             /**
              * Insert non-indexed texts
              */
-            while (notIndexed.isSet(textId))
+            while (notIndexedIt.isSet(textId))
             {
                 do {
                     tsbuilder[tsb_i] = *nit_i;
@@ -1169,12 +1171,12 @@ void FMIndex::maketables(ulong sampleLength, char tsType, CSA::DeltaVector & not
 
             // LF-mapping from '\0' does not work with this (pseudo) BWT.
             // Correct LF-mapping to the last char of the previous text:
-            p = textId - notIndexed.rank(textId); 
+            p = textId - notIndexedIt.rank(textId); 
         }
         else // Now c != '\0', do LF-mapping:
             p = C[c]+alphabetrank_i_tmp-1;
     }
-    while (textId > 0 && notIndexed.isSet(textId-1))
+    while (textId > 0 && notIndexedIt.isSet(textId-1))
     {
         do {
             -- tsb_i;
@@ -1219,7 +1221,7 @@ void FMIndex::maketables(ulong sampleLength, char tsType, CSA::DeltaVector & not
     for(ulong i = 0; i < sampleLength; i ++) {
         // Find next sampled text position
         while ((posOfSuccEndmarker - x) % samplerate != 0 
-               || notIndexed.isSet(textId)) // Loop over non-indexed
+               || notIndexedIt.isSet(textId)) // Loop over non-indexed
         {
             --x;
             assert(x != ~0lu);