diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-11-22 15:54:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 15:54:50 +0100 |
commit | b18ec11215b971d89a918153eb373502f78e8ec9 (patch) | |
tree | 7ddcf1e822b25e0fcae1311080e3e84630d481ce | |
parent | c3fd08cecf9a2a9f2e09c4df1c6758165dff48cb (diff) | |
parent | bcda1a2143815396ee156b3475ffe9cef343e13f (diff) |
Merge pull request #29423 from vespa-engine/balder/separate-hot-cold-path
Ensure the hot path is inlined, and cold path is in separate methods.
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp | 48 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h | 4 |
2 files changed, 32 insertions, 20 deletions
diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp index 431f386fa86..0bbdf89bab7 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.cpp @@ -138,8 +138,8 @@ public: bool allTermsHaveMatch(const SimplePhraseSearch::Children &terms, const vector<uint32_t> &eval_order, uint32_t doc_id) { - for (uint32_t i = 0; i < terms.size(); ++i) { - if (!terms[eval_order[i]]->seek(doc_id)) { + for (unsigned int order : eval_order) { + if (!terms[order]->seek(doc_id)) { return false; } } @@ -147,13 +147,18 @@ allTermsHaveMatch(const SimplePhraseSearch::Children &terms, const vector<uint32 } } // namespace -void +inline void SimplePhraseSearch::phraseSeek(uint32_t doc_id) { if (allTermsHaveMatch(getChildren(), _eval_order, doc_id)) { - AndSearch::doUnpack(doc_id); - if (PhraseMatcher(_childMatch, _eval_order, _iterators).hasMatch()) { - setDocId(doc_id); - } + matchPhrase(doc_id); + } +} + +void +SimplePhraseSearch::matchPhrase(uint32_t doc_id) { + AndSearch::doUnpack(doc_id); + if (PhraseMatcher(_childMatch, _eval_order, _iterators).hasMatch()) { + setDocId(doc_id); } } @@ -180,25 +185,30 @@ void SimplePhraseSearch::doSeek(uint32_t doc_id) { phraseSeek(doc_id); if (_strict) { - uint32_t next_candidate = doc_id; - while (getDocId() < doc_id || getDocId() == beginId()) { - getChildren()[0]->seek(next_candidate + 1); - next_candidate = getChildren()[0]->getDocId(); - if (isAtEnd(next_candidate)) { - setAtEnd(); - return; - } - // child must behave as strict. - assert(next_candidate > doc_id && next_candidate != beginId()); + doStrictSeek(doc_id); + } +} - phraseSeek(next_candidate); +void +SimplePhraseSearch::doStrictSeek(uint32_t doc_id) { + uint32_t next_candidate = doc_id; + while (getDocId() < doc_id || getDocId() == beginId()) { + getChildren()[0]->seek(next_candidate + 1); + next_candidate = getChildren()[0]->getDocId(); + if (isAtEnd(next_candidate)) { + setAtEnd(); + return; } + // child must behave as strict. + assert(next_candidate > doc_id && next_candidate != beginId()); + + phraseSeek(next_candidate); } } void SimplePhraseSearch::doUnpack(uint32_t doc_id) { - // All children has already been unpacked before this call is made. + // All children have already been unpacked before this call is made. _tmd.reset(doc_id); PhraseMatcher(_childMatch, _eval_order, _iterators).fillPositions(_tmd); diff --git a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h index 00e75f44844..8ee49183f51 100644 --- a/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h +++ b/searchlib/src/vespa/searchlib/queryeval/simple_phrase_search.h @@ -27,7 +27,9 @@ class SimplePhraseSearch : public AndSearch // Reuse this vector instead of allocating a new one when needed. std::vector<It> _iterators; - void phraseSeek(uint32_t doc_id); + VESPA_DLL_LOCAL void phraseSeek(uint32_t doc_id); + VESPA_DLL_LOCAL void matchPhrase(uint32_t doc_id) __attribute__((noinline)); + VESPA_DLL_LOCAL void doStrictSeek(uint32_t doc_id) __attribute__((noinline)); public: /** * Takes ownership of the contents of children. |