Construction time&space fix
authornvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 19 May 2009 12:30:53 +0000 (12:30 +0000)
committernvalimak <nvalimak@3cdefd35-fc62-479d-8e8d-bae585ffb9ca>
Tue, 19 May 2009 12:30:53 +0000 (12:30 +0000)
git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/TextCollection@401 3cdefd35-fc62-479d-8e8d-bae585ffb9ca

TextCollectionBuilder.cpp

index 67657bf..ff10f7b 100644 (file)
@@ -23,6 +23,7 @@ struct TCBuilderRep
     unsigned numberOfTexts;
     // Length of the longest text
     ulong maxTextLength;
+    ulong numberOfSamples;
 
 #ifdef TCB_TEST_BWT
     DynFMI *dynFMI;
@@ -40,6 +41,7 @@ TextCollectionBuilder::TextCollectionBuilder(unsigned samplerate)
     p_->n = 0;
     p_->samplerate = samplerate;
     p_->numberOfTexts = 0;
+    p_->numberOfSamples = 0;
     
     // Current params: 8 bytes, 15 MB, no samples
     p_->sa = new CSA::RLCSABuilder(8, 0, 15 * 1024 * 1024);
@@ -74,11 +76,11 @@ void TextCollectionBuilder::InsertText(uchar const * text)
     {
         p_->n += m;
         p_->numberOfTexts ++;
+        p_->numberOfSamples += (m-1)/p_->samplerate;
 
 #ifdef TCB_TEST_BWT
         p_->dynFMI->addText(text, m);
 #endif
-
         p_->sa->insertSequence((char*)text, m-1, 0);
         assert(p_->sa->isOk());
     }
@@ -137,7 +139,8 @@ TextCollection * TextCollectionBuilder::InitTextCollection()
             for (ulong i = 0; i < p_->n; ++i)
                 if (bwt[i] != bwtTest[i])
                 {
-                    std::cout << "i = " << i << ", bwt = " << (unsigned)bwt[i] << ", " << (unsigned)bwtTest[i] << std::endl;
+                    std::cout << "i = " << i << ", bwt = " << (unsigned)bwt[i] << ", " 
+                              << (unsigned)bwtTest[i] << std::endl;
                     assert(0);
                 }
             delete [] bwtTest;
@@ -145,7 +148,8 @@ TextCollection * TextCollectionBuilder::InitTextCollection()
 #endif // TCB_TEST_BWT
     }
 
-    TextCollection *result = new TCImplementation(bwt, (ulong)length, p_->samplerate, p_->numberOfTexts, p_->maxTextLength);
+    TextCollection *result = new TCImplementation(bwt, (ulong)length, 
+                      p_->samplerate, p_->numberOfTexts, p_->maxTextLength, p_->numberOfSamples);
     return result;
 }