From 975bd2cc156043da749bb43b2fcf63d1f30df63e Mon Sep 17 00:00:00 2001 From: nvalimak Date: Tue, 19 May 2009 12:31:36 +0000 Subject: [PATCH] Construction time&space fix git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/TextCollection@403 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- TextStorage.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/TextStorage.h b/TextStorage.h index 237bc44..3da3a1d 100644 --- a/TextStorage.h +++ b/TextStorage.h @@ -35,8 +35,7 @@ public: // Define a shortcut typedef TextCollection::TextPosition TextPosition; // Block size in DeltaVector - const static CSA::usint DV_BLOCK_SIZE = 16; - + const static CSA::usint DV_BLOCK_SIZE = 32; TextStorage(uchar *text, TextPosition n) : n_(n), text_(text), offsets_(0), numberOfTexts_(0) @@ -77,13 +76,23 @@ public: uchar * GetText(TextCollection::DocId docId) { - assert(docId < numberOfTexts_); + assert(docId < (TextCollection::DocId)numberOfTexts_); TextPosition offset = offsets_->select(docId); return &text_[offset]; } + TextCollection::DocId DocIdAtTextPos(TextCollection::TextPosition i) + { + assert(i < n_); + return offsets_->rank(i)-1; + } + TextCollection::TextPosition TextStartPos(TextCollection::DocId i) + { + assert(i < (TextCollection::DocId)numberOfTexts_); + return offsets_->select(i); + } private: void initOffsets() -- 2.17.1