diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-04-26 15:15:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-26 15:15:45 +0200 |
commit | 970e8747037a91dad423f073e08be2612bdeb71a (patch) | |
tree | 446664ddbb21e1a2bf4159789909d631b4896197 /searchlib/src/tests/queryeval/weak_and/rise_wand.hpp | |
parent | a0c71c001b3efc96276ff518c96860eff52d6c24 (diff) | |
parent | 87aa35392382a871a643248cb3d6efd05e2c4f4b (diff) |
Merge pull request #31057 from vespa-engine/balder/allow-stat-in-scorer
Allow scorer for wand to carry state
Diffstat (limited to 'searchlib/src/tests/queryeval/weak_and/rise_wand.hpp')
-rw-r--r-- | searchlib/src/tests/queryeval/weak_and/rise_wand.hpp | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp b/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp index 32e17014f98..c477be5cc62 100644 --- a/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp +++ b/searchlib/src/tests/queryeval/weak_and/rise_wand.hpp @@ -19,6 +19,7 @@ RiseWand<Scorer, Cmp>::RiseWand(const Terms &terms, uint32_t n) _streamIndices(new uint16_t[terms.size()]), _streamIndicesAux(new uint16_t[terms.size()]), _streamComparator(_streamDocIds), + _scorer(), _n(n), _limit(1), _streamScores(new score_t[terms.size()]), @@ -26,7 +27,7 @@ RiseWand<Scorer, Cmp>::RiseWand(const Terms &terms, uint32_t n) _terms(terms) { for (size_t i = 0; i < terms.size(); ++i) { - _terms[i].maxScore = Scorer::calculateMaxScore(terms[i]); + _terms[i].maxScore = _scorer.calculateMaxScore(terms[i]); _streamScores[i] = _terms[i].maxScore; _streams.push_back(terms[i].search); } @@ -46,8 +47,8 @@ RiseWand<Scorer, Cmp>::RiseWand(const Terms &terms, uint32_t n) template <typename Scorer, typename Cmp> RiseWand<Scorer, Cmp>::~RiseWand() { - for (size_t i = 0; i < _streams.size(); ++i) { - delete _streams[i]; + for (auto * stream : _streams) { + delete stream; } delete [] _streamScores; delete [] _streamIndicesAux; @@ -137,8 +138,7 @@ RiseWand<Scorer, Cmp>::_moveStreamsAndSort(const uint32_t numStreamsToMove) template <typename Scorer, typename Cmp> void -RiseWand<Scorer, Cmp>::_moveStreamsToDocAndSort(const uint32_t numStreamsToMove, - const docid_t desiredDocId) +RiseWand<Scorer, Cmp>::_moveStreamsToDocAndSort(const uint32_t numStreamsToMove, const docid_t desiredDocId) { for (uint32_t i=0; i<numStreamsToMove; ++i) { _streams[_streamIndices[i]]->seek(desiredDocId); @@ -195,7 +195,7 @@ RiseWand<Scorer, Cmp>::doUnpack(uint32_t docid) { score_t score = 0; for (size_t i = 0; i <= _lastPivotIdx; ++i) { - score += Scorer::calculateScore(_terms[_streamIndices[i]], docid); + score += _scorer.calculateScore(_terms[_streamIndices[i]], docid); } if (_scores.size() < _n || _scores.front() < score) { _scores.push(score); @@ -208,28 +208,5 @@ RiseWand<Scorer, Cmp>::doUnpack(uint32_t docid) } } -/** - ************ BEGIN STREAM COMPARTOR ********************* - */ -template <typename Scorer, typename Cmp> -RiseWand<Scorer, Cmp>::StreamComparator::StreamComparator( - const docid_t *streamDocIds) - : _streamDocIds(streamDocIds) -{ -} - -template <typename Scorer, typename Cmp> -inline bool -RiseWand<Scorer, Cmp>::StreamComparator::operator()(const uint16_t a, - const uint16_t b) -{ - if (_streamDocIds[a] < _streamDocIds[b]) return true; - return false; -} - -/** - ************ END STREAM COMPARTOR ********************* - */ - } // namespace rise |