-
-struct TCBuilderRep
-{
- unsigned samplerate;
- CSA::RLCSABuilder * sa;
-
- ulong n;
- // Total number of texts in the collection
- unsigned numberOfTexts;
- // Length of the longest text
- ulong maxTextLength;
- ulong numberOfSamples;
-
-#ifdef TCB_TEST_BWT
- DynFMI *dynFMI;
-#endif
-};
-
-/**
- * Init text collection
- *
- */
-TextCollectionBuilder::TextCollectionBuilder(unsigned samplerate, ulong estimatedInputLength)
- : p_(new struct TCBuilderRep())
-{
- p_->n = 0;
- p_->samplerate = samplerate;
- p_->numberOfTexts = 0;
- p_->numberOfSamples = 0;
-
- // Current params: 8 bytes, no samples, buffer size n/10 bytes.
- p_->sa = new CSA::RLCSABuilder(8, 0, estimatedInputLength/10);
- assert(p_->sa->isOk());
-
-#ifdef TCB_TEST_BWT
- uchar temp[256];
- for (unsigned i = 0; i < 255; ++i)
- temp[i] = i+1;
- temp[255] = 0;
- p_->dynFMI = new DynFMI(temp, 1, 255, false);
-#endif
-}
-
-TextCollectionBuilder::~TextCollectionBuilder()
-{
-#ifdef TCB_TEST_BWT
- delete p_->dynFMI;
-#endif
-
- delete p_->sa;
- delete p_;
-}
-
-void TextCollectionBuilder::InsertText(uchar const * text)
-{
- TextCollection::TextPosition m = std::strlen((char *)text) + 1;
- if (m > p_->maxTextLength)
- p_->maxTextLength = m; // Store length of the longest text seen so far.
-
- if (m > 1)
- {
- 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());
- }
- else
- {
- // FIXME indexing empty texts
- std::cerr << "TextCollectionBuilder::InsertText() error: can not index empty texts!" << std::endl;
- exit(1);
- }
-}
-
-
-TextCollection * TextCollectionBuilder::InitTextCollection()