aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeir Storli <geirst@vespa.ai>2024-04-16 20:44:17 +0200
committerGitHub <noreply@github.com>2024-04-16 20:44:17 +0200
commit643fe99939f30f62b3c16a6531ba79bab9025b30 (patch)
tree9596e556561295ba75ddb7858096c450954f0bc8
parent9ee70cf80666e1d6334bdf983e0bbb5e7b4f0332 (diff)
parent73700740182ab40ab62207717e6ac7fab64acc61 (diff)
Merge pull request #30920 from vespa-engine/havardpe/improve-non-strict-and-sorting
pass in_flow to intermediate sort functions
-rw-r--r--searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/blueprint.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/blueprint.h2
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp36
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h16
5 files changed, 29 insertions, 29 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
index 6ec1ffd460e..485410e0eba 100644
--- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
@@ -39,7 +39,7 @@ public:
return mixChildrenFields();
}
- void sort(Children &children, bool, bool) const override {
+ void sort(Children &children, InFlow) const override {
std::sort(children.begin(), children.end(), TieredGreaterEstimate());
}
diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp
index 43339b68999..d11ee25a7e5 100644
--- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp
@@ -619,7 +619,7 @@ IntermediateBlueprint::sort(InFlow in_flow)
{
resolve_strict(in_flow);
if (!opt_keep_order()) [[likely]] {
- sort(_children, in_flow.strict(), opt_sort_by_cost());
+ sort(_children, in_flow);
}
auto flow = my_flow(in_flow);
for (size_t i = 0; i < _children.size(); ++i) {
diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h
index 1501289c590..a443f34f856 100644
--- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h
+++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h
@@ -499,7 +499,7 @@ public:
virtual HitEstimate combine(const std::vector<HitEstimate> &data) const = 0;
virtual FieldSpecBaseList exposeFields() const = 0;
- virtual void sort(Children &children, bool strict, bool sort_by_cost) const = 0;
+ virtual void sort(Children &children, InFlow in_flow) const = 0;
virtual SearchIteratorUP
createIntermediateSearch(MultiSearch::Children subSearches, fef::MatchData &md) const = 0;
diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp
index 449a6a044b9..2fd632f9b97 100644
--- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp
@@ -162,10 +162,10 @@ AndNotBlueprint::get_replacement()
}
void
-AndNotBlueprint::sort(Children &children, bool strict, bool sort_by_cost) const
+AndNotBlueprint::sort(Children &children, InFlow in_flow) const
{
- if (sort_by_cost) {
- AndNotFlow::sort(children, strict);
+ if (opt_sort_by_cost()) {
+ AndNotFlow::sort(children, in_flow.strict());
} else {
if (children.size() > 2) {
std::sort(children.begin() + 1, children.end(), TieredGreaterEstimate());
@@ -257,12 +257,12 @@ AndBlueprint::get_replacement()
}
void
-AndBlueprint::sort(Children &children, bool strict, bool sort_by_cost) const
+AndBlueprint::sort(Children &children, InFlow in_flow) const
{
- if (sort_by_cost) {
- AndFlow::sort(children, strict);
- if (strict && opt_allow_force_strict()) {
- AndFlow::reorder_for_extra_strictness(children, true, 3);
+ if (opt_sort_by_cost()) {
+ AndFlow::sort(children, in_flow.strict());
+ if (opt_allow_force_strict()) {
+ AndFlow::reorder_for_extra_strictness(children, in_flow, 3);
}
} else {
std::sort(children.begin(), children.end(), TieredLessEstimate());
@@ -360,10 +360,10 @@ OrBlueprint::get_replacement()
}
void
-OrBlueprint::sort(Children &children, bool strict, bool sort_by_cost) const
+OrBlueprint::sort(Children &children, InFlow in_flow) const
{
- if (sort_by_cost) {
- OrFlow::sort(children, strict);
+ if (opt_sort_by_cost()) {
+ OrFlow::sort(children, in_flow.strict());
} else {
std::sort(children.begin(), children.end(), TieredGreaterEstimate());
}
@@ -449,7 +449,7 @@ WeakAndBlueprint::exposeFields() const
}
void
-WeakAndBlueprint::sort(Children &, bool, bool) const
+WeakAndBlueprint::sort(Children &, InFlow) const
{
// order needs to stay the same as _weights
}
@@ -511,10 +511,10 @@ NearBlueprint::exposeFields() const
}
void
-NearBlueprint::sort(Children &children, bool strict, bool sort_by_cost) const
+NearBlueprint::sort(Children &children, InFlow in_flow) const
{
- if (sort_by_cost) {
- AndFlow::sort(children, strict);
+ if (opt_sort_by_cost()) {
+ AndFlow::sort(children, in_flow.strict());
} else {
std::sort(children.begin(), children.end(), TieredLessEstimate());
}
@@ -576,7 +576,7 @@ ONearBlueprint::exposeFields() const
}
void
-ONearBlueprint::sort(Children &, bool, bool) const
+ONearBlueprint::sort(Children &, InFlow) const
{
// ordered near cannot sort children here
}
@@ -662,7 +662,7 @@ RankBlueprint::get_replacement()
}
void
-RankBlueprint::sort(Children &, bool, bool) const
+RankBlueprint::sort(Children &, InFlow) const
{
}
@@ -743,7 +743,7 @@ SourceBlenderBlueprint::exposeFields() const
}
void
-SourceBlenderBlueprint::sort(Children &, bool, bool) const
+SourceBlenderBlueprint::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 5d6d098510f..5b7b5b701b5 100644
--- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h
+++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h
@@ -21,7 +21,7 @@ public:
void optimize_self(OptimizePass pass) override;
AndNotBlueprint * asAndNot() noexcept final { return this; }
Blueprint::UP get_replacement() override;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
fef::MatchData &md) const override;
@@ -48,7 +48,7 @@ public:
void optimize_self(OptimizePass pass) override;
AndBlueprint * asAnd() noexcept final { return this; }
Blueprint::UP get_replacement() override;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
fef::MatchData &md) const override;
@@ -72,7 +72,7 @@ public:
void optimize_self(OptimizePass pass) override;
OrBlueprint * asOr() noexcept final { return this; }
Blueprint::UP get_replacement() override;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
fef::MatchData &md) const override;
@@ -96,7 +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;
- void sort(Children &children, bool strict, bool sort_on_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
bool always_needs_unpack() const override;
WeakAndBlueprint * asWeakAnd() noexcept final { return this; }
SearchIterator::UP
@@ -126,7 +126,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;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
SearchIteratorUP createSearch(fef::MatchData &md) const override;
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
@@ -148,7 +148,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;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
SearchIteratorUP createSearch(fef::MatchData &md) const override;
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
@@ -168,7 +168,7 @@ public:
FieldSpecBaseList exposeFields() const override;
void optimize_self(OptimizePass pass) override;
Blueprint::UP get_replacement() override;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
bool isRank() const noexcept final { return true; }
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
@@ -196,7 +196,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;
- void sort(Children &children, bool strict, bool sort_by_cost) const override;
+ void sort(Children &children, InFlow in_flow) const override;
SearchIterator::UP
createIntermediateSearch(MultiSearch::Children subSearches,
fef::MatchData &md) const override;