diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-09-29 07:51:21 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-09-29 14:24:52 +0000 |
commit | 44723c531ec95b05394e872420fa97aa210ea5c3 (patch) | |
tree | db37d1d5e79b6d0b1c7a0d6a444bdeb8d2b18e47 /searchlib/src | |
parent | 507e6eef0f00fc55888fee1ab0afc3af8f70eb72 (diff) |
Lift out single iterators if they are leafs and tfmd is not needed.
Diffstat (limited to 'searchlib/src')
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/blueprint.h | 2 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index 8d230b6ec01..882db00c059 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -251,6 +251,7 @@ public: virtual bool isEquiv() const { return false; } virtual bool isWhiteList() const { return false; } virtual bool isIntermediate() const { return false; } + virtual bool isLeaf() const { return false; } virtual bool isAnd() const { return false; } virtual bool isAndNot() const { return false; } virtual bool isOr() const { return false; } @@ -396,6 +397,7 @@ public: void fetchPostings(const ExecuteInfo &execInfo) override; void freeze() final; SearchIteratorUP createSearch(fef::MatchData &md, bool strict) const override; + bool isLeaf() const final { return true; } virtual bool getRange(vespalib::string & from, vespalib::string & to) const; virtual SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const = 0; diff --git a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp index 55009e714b9..f09ad4103d8 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp @@ -96,11 +96,15 @@ SearchIterator::UP WeightedSetTermBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool) const { assert(tfmda.size() == 1); + if ((_terms.size() == 1) && tfmda[0]->isNotNeeded() && _terms[0]->isLeaf()) { + return static_cast<LeafBlueprint &>(*_terms[0]).createLeafSearch(tfmda, true); + } fef::MatchData::UP md = _layout.createMatchData(); - std::vector<SearchIterator*> children(_terms.size()); - for (size_t i = 0; i < _terms.size(); ++i) { + std::vector<SearchIterator*> children; + children.reserve(_terms.size()); + for (const auto & _term : _terms) { // TODO: pass ownership with unique_ptr - children[i] = _terms[i]->createSearch(*md, true).release(); + children.push_back(_term->createSearch(*md, true).release()); } return WeightedSetTermSearch::create(children, *tfmda[0], _children_field.isFilter(), _weights, std::move(md)); } |