summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-04-18 13:04:17 +0200
committerGitHub <noreply@github.com>2024-04-18 13:04:17 +0200
commit2230b5937514d9563311b8b9e395672eaa6786a4 (patch)
treea377853817f241dae4eaf213fe785b7c70b3b6bd /searchlib
parentb03ee6523f55c6c8ea486da35259ecb95af1fbd3 (diff)
parent4bb8c283de1d9ea1e93b248b018dfd5ac1f6d86c (diff)
Merge pull request #30956 from vespa-engine/havardpe/optimize-single-child-vespa-wand
optimize weak and with single child
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h1
3 files changed, 11 insertions, 1 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
index 72dd2b5a4ad..bddc9f92111 100644
--- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp
@@ -869,7 +869,7 @@ TEST("AND_NOT AND AND_NOT collapsing into full source blender optimization") {
TEST("test single child optimization") {
InvalidSelector selector;
//-------------------------------------------------------------------------
- Blueprint::UP top = make::ANDNOT().add(make::AND().add(make::RANK().add(make::OR().add(make::SB(selector).source(2).add(make::RANK().leaf(42))))));
+ Blueprint::UP top = make::ANDNOT().add(make::AND().add(make::RANK().add(make::OR().add(make::WEAKAND(100).add(make::SB(selector).source(2).add(make::RANK().leaf(42)))))));
//-------------------------------------------------------------------------
Blueprint::UP expect = make::SB(selector).source(2).leaf(42);
//-------------------------------------------------------------------------
diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp
index 2fd632f9b97..2a0f1de0e44 100644
--- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp
@@ -448,6 +448,15 @@ WeakAndBlueprint::exposeFields() const
return {};
}
+Blueprint::UP
+WeakAndBlueprint::get_replacement()
+{
+ if (childCnt() == 1) {
+ return removeChild(0);
+ }
+ return {};
+}
+
void
WeakAndBlueprint::sort(Children &, InFlow) const
{
diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h
index 5b7b5b701b5..dfed40f4d1b 100644
--- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h
+++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h
@@ -96,6 +96,7 @@ public:
FlowStats calculate_flow_stats(uint32_t docid_limit) const final;
HitEstimate combine(const std::vector<HitEstimate> &data) const override;
FieldSpecBaseList exposeFields() const override;
+ Blueprint::UP get_replacement() override;
void sort(Children &children, InFlow in_flow) const override;
bool always_needs_unpack() const override;
WeakAndBlueprint * asWeakAnd() noexcept final { return this; }