X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=TextStorage.h;fp=TextStorage.h;h=1f809b8e4878d186aee720a0cdf802dc05685617;hb=13e254b7c0ee22dffbc7c3125cee0408f9b375da;hp=6294c6bda9484e37aac9bad6e3e9ac3f96bfda50;hpb=e4b6bdc7cc2a1372e4d4dae50acac55cebcc7e9b;p=SXSI%2FTextCollection.git diff --git a/TextStorage.h b/TextStorage.h index 6294c6b..1f809b8 100644 --- a/TextStorage.h +++ b/TextStorage.h @@ -68,20 +68,22 @@ public: virtual ~TextStorage() { + delete offit_; + offit_ = 0; delete offsets_; - offsets_ = 0; + offsets_ = 0; } TextCollection::DocId DocIdAtTextPos(TextCollection::TextPosition i) const { assert(i < n_); - return offsets_->rank(i)-1; + return offit_->rank(i)-1; } TextCollection::TextPosition TextStartPos(TextCollection::DocId i) const { assert(i < (TextCollection::DocId)numberOfTexts_); - return offsets_->select(i); + return offit_->select(i); } bool IsEndmarker(TextCollection::TextPosition i) const @@ -89,7 +91,7 @@ public: assert(i < n_); if (i >= n_ - 1) return true; - return offsets_->isSet(i+1); + return offit_->isSet(i+1); } @@ -100,7 +102,7 @@ protected: const static CSA::usint DV_BLOCK_SIZE = 32; TextStorage(uchar const * text, TextPosition n) - : n_(n), offsets_(0), numberOfTexts_(0) + : n_(n), offsets_(0), offit_(0), numberOfTexts_(0) { // Delta encoded bitvector of text offsets. CSA::DeltaEncoder encoder(DV_BLOCK_SIZE); @@ -113,7 +115,8 @@ protected: offsets_ = new CSA::DeltaVector(encoder, n_); - numberOfTexts_ = offsets_->rank(n_ - 1); + offit_ = new CSA::DeltaVector::Iterator(*(offsets_)); + numberOfTexts_ = offit_->rank(n_ - 1); } TextStorage(std::FILE *); @@ -121,6 +124,7 @@ protected: TextPosition n_; CSA::DeltaVector *offsets_; + CSA::DeltaVector::Iterator *offit_; TextPosition numberOfTexts_; }; @@ -161,7 +165,7 @@ public: { assert(docId < (TextCollection::DocId)numberOfTexts_); - TextPosition offset = offsets_->select(docId); + TextPosition offset = offit_->select(docId); return &text_[offset]; } @@ -170,7 +174,7 @@ public: assert(i < (TextCollection::DocId)numberOfTexts_); assert(j < (TextCollection::DocId)numberOfTexts_); - TextPosition offset = offsets_->select(i); + TextPosition offset = offit_->select(i); return &text_[offset]; }