Skip to content

Commit

Permalink
Merge pull request #32444 from vespa-engine/toregge/pass-word-along-w…
Browse files Browse the repository at this point in the history
…ith-counts-to-posting-list-reader

Pass word along with counts to posting list reader.
  • Loading branch information
geirst committed Sep 20, 2024
2 parents 706b08c + 9f86976 commit 056966a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion searchlib/src/vespa/searchlib/diskindex/fieldreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FieldReader::readCounts()
{
PostingListCounts counts;
_dictFile->readWord(_word, _oldWordNum, counts);
_oldposoccfile->readCounts(counts);
_oldposoccfile->read_word_and_counts(_word, counts);
if (_oldWordNum != noWordNumHigh()) {
_wordNum = _wordNumMapper.map(_oldWordNum);
assert(_wordNum != noWordNum());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ Zc4PostingReader<bigEndian>::read_word_start()

template <bool bigEndian>
void
Zc4PostingReader<bigEndian>::set_counts(const PostingListCounts &counts)
Zc4PostingReader<bigEndian>::set_word_and_counts(const std::string& word, const index::PostingListCounts& counts)
{
Zc4PostingReaderBase::set_counts(*_decodeContext, counts);
Zc4PostingReaderBase::set_word_and_counts(*_decodeContext, word, counts);
}

template <bool bigEndian>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Zc4PostingReader : public Zc4PostingReaderBase
Zc4PostingReader &operator=(Zc4PostingReader &&) = delete;
~Zc4PostingReader();
void read_doc_id_and_features(index::DocIdAndFeatures &features);
void set_counts(const index::PostingListCounts &counts);
void set_word_and_counts(const std::string& word, const index::PostingListCounts& counts);
void set_decode_features(DecodeContext *decode_features);
DecodeContext &get_decode_features() const { return *_decodeContext; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ Zc4PostingReaderBase::Zc4PostingReaderBase(bool dynamic_k)
_l4_skip(),
_chunkNo(0),
_features_size(0),
_word(),
_counts(),
_residue(0)
{
Expand Down Expand Up @@ -295,9 +296,10 @@ Zc4PostingReaderBase::read_word_start(DecodeContext64Base &decode_context)
}

void
Zc4PostingReaderBase::set_counts(DecodeContext64Base &decode_context, const PostingListCounts &counts)
Zc4PostingReaderBase::set_word_and_counts(bitcompression::DecodeContext64Base &decode_context, const std::string& word, const index::PostingListCounts &counts)
{
assert(!_has_more && _residue == 0); // Previous words must have been read.
_word = word;
_counts = counts;
assert((_counts._numDocs == 0) == (_counts._bitLength == 0));
if (_counts._numDocs > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Zc4PostingReaderBase

// Variable for validating chunk information while reading
uint64_t _features_size;
std::string _word;
index::PostingListCounts _counts;

uint32_t _residue; // Number of unread documents after word header
Expand All @@ -124,7 +125,7 @@ class Zc4PostingReaderBase
Zc4PostingReaderBase &operator=(Zc4PostingReaderBase &&) = delete;
~Zc4PostingReaderBase();
void read_doc_id_and_features(index::DocIdAndFeatures &features);
void set_counts(bitcompression::DecodeContext64Base &decode_context, const index::PostingListCounts &counts);
void set_word_and_counts(bitcompression::DecodeContext64Base &decode_context, const std::string& word, const index::PostingListCounts& counts);
ComprFileReadContext &get_read_context() { return _readContext; }
Zc4PostingParams &get_posting_params() { return _posting_params; }
};
Expand Down
4 changes: 2 additions & 2 deletions searchlib/src/vespa/searchlib/diskindex/zcposting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ Zc4PostingSeqRead::readDocIdAndFeatures(DocIdAndFeatures &features)
}

void
Zc4PostingSeqRead::readCounts(const PostingListCounts &counts)
Zc4PostingSeqRead::read_word_and_counts(const std::string& word, const PostingListCounts& counts)
{
_reader.set_counts(counts);
_reader.set_word_and_counts(word, counts);
}


Expand Down
2 changes: 1 addition & 1 deletion searchlib/src/vespa/searchlib/diskindex/zcposting.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Zc4PostingSeqRead : public index::PostingListFileSeqRead
using PostingListParams = index::PostingListParams;

void readDocIdAndFeatures(DocIdAndFeatures &features) override;
void readCounts(const PostingListCounts &counts) override; // Fill in for next word
void read_word_and_counts(const std::string& word, const PostingListCounts &counts) override; // Fill in for next word
bool open(const std::string &name, const TuneFileSeqRead &tuneFileRead) override;
bool close() override;
void getParams(PostingListParams &params) override;
Expand Down
2 changes: 1 addition & 1 deletion searchlib/src/vespa/searchlib/index/postinglistfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PostingListFileSeqRead {
/**
* Read counts for a word.
*/
virtual void readCounts(const PostingListCounts &counts) = 0;
virtual void read_word_and_counts(const std::string& word, const PostingListCounts& counts) = 0;

/**
* Open posting list file for sequential read.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ FakeZcFilterOcc::validate_read(const FakeWord &fw) const
PostingListCounts counts;
counts._bitLength = _compressedBits;
counts._numDocs = _hitDocs;
reader.set_counts(counts);
reader.set_word_and_counts(fw.getName(), counts);
auto word_pos_iterator(fw._wordPosFeatures.begin());
auto word_pos_iterator_end(fw._wordPosFeatures.end());
DocIdAndPosOccFeatures check_features;
Expand Down

0 comments on commit 056966a

Please sign in to comment.