X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=TextStorage.cpp;fp=TextStorage.cpp;h=beac53a103388b1ed5626344e40f17f352f442b4;hb=13e254b7c0ee22dffbc7c3125cee0408f9b375da;hp=77c61acc463da555bc57006361e6e60aa9e519ba;hpb=e4b6bdc7cc2a1372e4d4dae50acac55cebcc7e9b;p=SXSI%2FTextCollection.git diff --git a/TextStorage.cpp b/TextStorage.cpp index 77c61ac..beac53a 100644 --- a/TextStorage.cpp +++ b/TextStorage.cpp @@ -65,7 +65,7 @@ TextStorage * TextStorage::Load(std::FILE *file) } TextStorage::TextStorage(std::FILE * file) - : n_(0), offsets_(0), numberOfTexts_(0) + : n_(0), offsets_(0), offit_(0), numberOfTexts_(0) { if (std::fread(&(this->n_), sizeof(TextPosition), 1, file) != 1) throw std::runtime_error("TextStorage::Load(): file read error (n_)."); @@ -74,6 +74,7 @@ TextStorage::TextStorage(std::FILE * file) throw std::runtime_error("TextStorage::Load(): file read error (numberOfTexts_)."); offsets_ = new CSA::DeltaVector(file); + offit_ = new CSA::DeltaVector::Iterator(*offsets_); } void TextStorage::Save(FILE *file, char type) const @@ -142,10 +143,10 @@ uchar * TextStorageLzIndex::GetText(TextCollection::DocId docId) const { assert(docId < (TextCollection::DocId)numberOfTexts_); - TextPosition from = offsets_->select(docId); + TextPosition from = offit_->select(docId); TextPosition to = 0; if (docId < (TextCollection::DocId)numberOfTexts_ - 1) - to = offsets_->select(docId + 1) - 1; + to = offit_->select(docId + 1) - 1; else to = n_-1; @@ -162,10 +163,10 @@ uchar * TextStorageLzIndex::GetText(TextCollection::DocId i, TextCollection::Doc assert(i < (TextCollection::DocId)numberOfTexts_); assert(j < (TextCollection::DocId)numberOfTexts_); - TextPosition from = offsets_->select(i); + TextPosition from = offit_->select(i); TextPosition to = 0; if (j < (TextCollection::DocId)numberOfTexts_ - 1) - to = offsets_->select(j + 1) - 1; + to = offit_->select(j + 1) - 1; else to = n_-1; @@ -177,7 +178,7 @@ uchar * TextStorageLzIndex::GetText(TextCollection::DocId i, TextCollection::Doc while (i < j && i < (TextCollection::DocId)numberOfTexts_) { ++i; - text[offsets_->select(i) - 1 - from] = 0; + text[offit_->select(i) - 1 - from] = 0; } text[l-1] = 0; return text;