}
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_).");
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
{
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;
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;
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;