diff options
author | Håvard Pettersen <havardpe@yahooinc.com> | 2024-02-27 15:44:58 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@yahooinc.com> | 2024-02-27 15:44:58 +0000 |
commit | a400b80bcc006f626cb253d114fc0878794c4a20 (patch) | |
tree | 1612b9254c09b52c090872e0e04ea30110fa3b4c /searchlib | |
parent | 1720954b69970e93aa442b26f1cc08ce4d643b8e (diff) |
split estimates from incremental flow calculations
replace FlowCalc with AnyFlow and add RankFlow and BlenderFlow
Diffstat (limited to 'searchlib')
7 files changed, 240 insertions, 162 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp index 1af9ee6cff7..968e006622f 100644 --- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp @@ -24,8 +24,8 @@ auto opts = Blueprint::Options::all(); class MyOr : public IntermediateBlueprint { private: - FlowCalc make_flow_calc(InFlow in_flow) const override { - return flow_calc<OrFlow>(in_flow); + AnyFlow my_flow(InFlow in_flow) const override { + return AnyFlow::create<OrFlow>(in_flow); } public: FlowStats calculate_flow_stats(uint32_t) const final { diff --git a/searchlib/src/tests/queryeval/flow/queryeval_flow_test.cpp b/searchlib/src/tests/queryeval/flow/queryeval_flow_test.cpp index be70a037c98..4562f8cb50e 100644 --- a/searchlib/src/tests/queryeval/flow/queryeval_flow_test.cpp +++ b/searchlib/src/tests/queryeval/flow/queryeval_flow_test.cpp @@ -128,33 +128,31 @@ struct ExpectFlow { bool strict; }; +std::vector<FlowStats> make_flow_stats(const std::vector<double> &est_list, size_t n) { + std::vector<FlowStats> result; + for (size_t i = 0; i < n; ++i) { + result.emplace_back(est_list[i], 123.0, 456.0); + } + return result; +} + void verify_flow(auto flow, const std::vector<double> &est_list, const std::vector<ExpectFlow> &expect) { - FlowCalc calc = flow_calc<decltype(flow)>(InFlow(flow.strict(), flow.flow())); AnyFlow any_flow = AnyFlow::create<decltype(flow)>(InFlow(flow.strict(), flow.flow())); ASSERT_EQ(est_list.size() + 1, expect.size()); - for (size_t i = 0; i < expect.size(); ++i) { + for (size_t i = 0; i < est_list.size(); ++i) { EXPECT_EQ(any_flow.flow(), flow.flow()); - EXPECT_EQ(any_flow.estimate(), flow.estimate()); EXPECT_EQ(any_flow.strict(), flow.strict()); EXPECT_DOUBLE_EQ(flow.flow(), expect[i].flow); - EXPECT_DOUBLE_EQ(flow.estimate(), expect[i].est); EXPECT_EQ(flow.strict(), expect[i].strict); - if (i < est_list.size()) { - EXPECT_EQ(calc(est_list[i]), flow.flow()); - flow.add(est_list[i]); - any_flow.add(est_list[i]); - } else { - EXPECT_EQ(calc(0.5), flow.flow()); - } - } -} - -void verify_flow_calc(FlowCalc flow_calc, const std::vector<double> &est_list, const std::vector<double> &expect) { - ASSERT_EQ(est_list.size() + 1, expect.size()); - for (size_t i = 0; i < est_list.size(); ++i) { - EXPECT_DOUBLE_EQ(flow_calc(est_list[i]), expect[i]); + EXPECT_DOUBLE_EQ(flow.estimate_of(make_flow_stats(est_list, i)), expect[i].est); + any_flow.add(est_list[i]); + flow.add(est_list[i]); } - EXPECT_DOUBLE_EQ(flow_calc(0.5), expect.back()); + EXPECT_EQ(any_flow.flow(), flow.flow()); + EXPECT_EQ(any_flow.strict(), flow.strict()); + EXPECT_DOUBLE_EQ(flow.flow(), expect.back().flow); + EXPECT_EQ(flow.strict(), expect.back().strict); + EXPECT_DOUBLE_EQ(flow.estimate_of(make_flow_stats(est_list, est_list.size())), expect.back().est); } TEST(FlowTest, full_and_flow) { @@ -171,9 +169,9 @@ TEST(FlowTest, partial_and_flow) { for (double in: {1.0, 0.5, 0.25}) { verify_flow(AndFlow(in), {0.4, 0.7, 0.2}, {{in, 0.0, false}, - {in*0.4, in*0.4, false}, - {in*0.4*0.7, in*0.4*0.7, false}, - {in*0.4*0.7*0.2, in*0.4*0.7*0.2, false}}); + {in*0.4, 0.4, false}, + {in*0.4*0.7, 0.4*0.7, false}, + {in*0.4*0.7*0.2, 0.4*0.7*0.2, false}}); } } @@ -194,9 +192,9 @@ TEST(FlowTest, partial_or_flow) { for (double in: {1.0, 0.5, 0.25}) { verify_flow(OrFlow(in), {0.4, 0.7, 0.2}, {{in, 0.0, false}, - {in*0.6, 1.0-in*0.6, false}, - {in*0.6*0.3, 1.0-in*0.6*0.3, false}, - {in*0.6*0.3*0.8, 1.0-in*0.6*0.3*0.8, false}}); + {in*0.6, 1.0-0.6, false}, + {in*0.6*0.3, 1.0-0.6*0.3, false}, + {in*0.6*0.3*0.8, 1.0-0.6*0.3*0.8, false}}); } } @@ -214,37 +212,49 @@ TEST(FlowTest, partial_and_not_flow) { for (double in: {1.0, 0.5, 0.25}) { verify_flow(AndNotFlow(in), {0.4, 0.7, 0.2}, {{in, 0.0, false}, - {in*0.4, in*0.4, false}, - {in*0.4*0.3, in*0.4*0.3, false}, - {in*0.4*0.3*0.8, in*0.4*0.3*0.8, false}}); + {in*0.4, 0.4, false}, + {in*0.4*0.3, 0.4*0.3, false}, + {in*0.4*0.3*0.8, 0.4*0.3*0.8, false}}); } } -TEST(FlowTest, full_first_flow_calc) { +TEST(FlowTest, full_rank_flow) { for (bool strict: {false, true}) { - verify_flow_calc(first_flow_calc(strict), - {0.4, 0.7, 0.2}, {1.0, 0.4, 0.4, 0.4}); + verify_flow(RankFlow(strict), {0.4, 0.7, 0.2}, + {{1.0, 0.0, strict}, + {0.0, 0.4, false}, + {0.0, 0.4, false}, + {0.0, 0.4, false}}); } } -TEST(FlowTest, partial_first_flow_calc) { +TEST(FlowTest, partial_rank_flow) { for (double in: {1.0, 0.5, 0.25}) { - verify_flow_calc(first_flow_calc(in), - {0.4, 0.7, 0.2}, {in, in*0.4, in*0.4, in*0.4}); + verify_flow(RankFlow(in), {0.4, 0.7, 0.2}, + {{in, 0.0, false}, + {0.0, 0.4, false}, + {0.0, 0.4, false}, + {0.0, 0.4, false}}); } } -TEST(FlowTest, full_full_flow_calc) { +TEST(FlowTest, full_blender_flow) { for (bool strict: {false, true}) { - verify_flow_calc(full_flow_calc(strict), - {0.4, 0.7, 0.2}, {1.0, 1.0, 1.0, 1.0}); + verify_flow(BlenderFlow(strict), {0.4, 0.7, 0.2}, + {{1.0, 0.0, strict}, + {1.0, 1.0-0.6, strict}, + {1.0, 1.0-0.6*0.3, strict}, + {1.0, 1.0-0.6*0.3*0.8, strict}}); } } -TEST(FlowTest, partial_full_flow_calc) { +TEST(FlowTest, partial_blender_flow) { for (double in: {1.0, 0.5, 0.25}) { - verify_flow_calc(full_flow_calc(in), - {0.4, 0.7, 0.2}, {in, in, in, in}); + verify_flow(BlenderFlow(in), {0.4, 0.7, 0.2}, + {{in, 0.0, false}, + {in, 1.0-0.6, false}, + {in, 1.0-0.6*0.3, false}, + {in, 1.0-0.6*0.3*0.8, false}}); } } @@ -271,6 +281,37 @@ TEST(FlowTest, flow_cost) { EXPECT_DOUBLE_EQ(dual_ordered_cost_of<OrFlow>(data, true), 0.6 + 0.5 + 0.4); EXPECT_DOUBLE_EQ(dual_ordered_cost_of<AndNotFlow>(data, false), 1.1 + 0.4*1.2 + 0.4*0.3*1.3); EXPECT_DOUBLE_EQ(dual_ordered_cost_of<AndNotFlow>(data, true), 0.6 + 0.4*1.2 + 0.4*0.3*1.3); + EXPECT_DOUBLE_EQ(dual_ordered_cost_of<RankFlow>(data, false), 1.1); + EXPECT_DOUBLE_EQ(dual_ordered_cost_of<RankFlow>(data, true), 0.6); + EXPECT_DOUBLE_EQ(dual_ordered_cost_of<BlenderFlow>(data, false), 1.3); + EXPECT_DOUBLE_EQ(dual_ordered_cost_of<BlenderFlow>(data, true), 0.6); +} + +TEST(FlowTest, rank_flow_cost_accumulation_is_first) { + for (bool strict: {false, true}) { + auto flow = AnyFlow::create<RankFlow>(strict); + double cost = 0.0; + flow.update_cost(cost, 5.0); + EXPECT_EQ(cost, 5.0); + flow.add(0.5); // next child + flow.update_cost(cost, 5.0); + EXPECT_EQ(cost, 5.0); + } +} + +TEST(FlowTest, blender_flow_cost_accumulation_is_max) { + for (bool strict: {false, true}) { + auto flow = AnyFlow::create<BlenderFlow>(strict); + double cost = 0.0; + flow.update_cost(cost, 5.0); + EXPECT_EQ(cost, 5.0); + flow.add(0.5); // next child + flow.update_cost(cost, 3.0); + EXPECT_EQ(cost, 5.0); + flow.add(0.5); // next child + flow.update_cost(cost, 7.0); + EXPECT_EQ(cost, 7.0); + } } TEST(FlowTest, optimal_and_flow) { @@ -328,11 +369,11 @@ TEST(FlowTest, optimal_and_not_flow) { double max_cost = 0.0; AndNotFlow::sort(data, strict); EXPECT_EQ(data[0], first); - EXPECT_EQ(ordered_cost_of<AndNotFlow>(data, strict), min_cost); + EXPECT_DOUBLE_EQ(ordered_cost_of<AndNotFlow>(data, strict), min_cost); auto check = [&](const std::vector<FlowStats> &my_data) noexcept { if (my_data[0] == first) { double my_cost = ordered_cost_of<AndNotFlow>(my_data, strict); - EXPECT_LE(min_cost, my_cost); + EXPECT_LE(min_cost, my_cost + 1e-9); max_cost = std::max(max_cost, my_cost); } }; diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp index 5a225328003..15eb4c0b4fb 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.cpp @@ -572,11 +572,11 @@ IntermediateBlueprint::optimize(Blueprint* &self, OptimizePass pass) double IntermediateBlueprint::sort(InFlow in_flow, const Options &opts) { - auto flow_calc = make_flow_calc(in_flow); sort(_children, in_flow.strict(), opts.sort_by_cost()); + auto flow = my_flow(in_flow); for (size_t i = 0; i < _children.size(); ++i) { - double next_rate = flow_calc(_children[i]->estimate()); - _children[i]->sort(InFlow(in_flow.strict() && inheritStrict(i), next_rate), opts); + _children[i]->sort(InFlow(flow.strict(), flow.flow()), opts); + flow.add(_children[i]->estimate()); } // TODO: better cost estimate (due to known in-flow and eagerness) return in_flow.strict() ? strict_cost() : in_flow.rate() * cost(); @@ -646,11 +646,12 @@ IntermediateBlueprint::visitMembers(vespalib::ObjectVisitor &visitor) const void IntermediateBlueprint::fetchPostings(const ExecuteInfo &execInfo) { - FlowCalc flow_calc = make_flow_calc(InFlow(execInfo.is_strict(), execInfo.hit_rate())); + auto flow = my_flow(InFlow(execInfo.is_strict(), execInfo.hit_rate())); for (size_t i = 0; i < _children.size(); ++i) { + double nextHitRate = flow.flow(); Blueprint & child = *_children[i]; - double nextHitRate = flow_calc(child.estimate()); child.fetchPostings(ExecuteInfo::create(execInfo.is_strict() && inheritStrict(i), nextHitRate, execInfo)); + flow.add(child.estimate()); } } diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index 0c08e6aedf5..b19ae699fdc 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -386,7 +386,7 @@ private: bool infer_want_global_filter() const; size_t count_termwise_nodes(const UnpackInfo &unpack) const; - virtual FlowCalc make_flow_calc(InFlow in_flow) const = 0; + virtual AnyFlow my_flow(InFlow in_flow) const = 0; protected: // returns an empty collection if children have empty or diff --git a/searchlib/src/vespa/searchlib/queryeval/flow.h b/searchlib/src/vespa/searchlib/queryeval/flow.h index 9dd6d82a491..785a4c5e63c 100644 --- a/searchlib/src/vespa/searchlib/queryeval/flow.h +++ b/searchlib/src/vespa/searchlib/queryeval/flow.h @@ -117,12 +117,31 @@ struct MinOrCost { } }; -template <typename ADAPTER, typename T, typename F> -double estimate_of(ADAPTER adapter, const T &children, F flow) { +template <typename ADAPTER, typename T> +double estimate_of_and(ADAPTER adapter, const T &children) { + double flow = children.empty() ? 0.0 : adapter.estimate(children[0]); + for (size_t i = 1; i < children.size(); ++i) { + flow *= adapter.estimate(children[i]); + } + return flow; +} + +template <typename ADAPTER, typename T> +double estimate_of_or(ADAPTER adapter, const T &children) { + double flow = 1.0; for (const auto &child: children) { - flow.add(adapter.estimate(child)); + flow *= (1.0 - adapter.estimate(child)); + } + return (1.0 - flow); +} + +template <typename ADAPTER, typename T> +double estimate_of_and_not(ADAPTER adapter, const T &children) { + double flow = children.empty() ? 0.0 : adapter.estimate(children[0]); + for (size_t i = 1; i < children.size(); ++i) { + flow *= (1.0 - adapter.estimate(children[i])); } - return flow.estimate(); + return flow; } template <template <typename> typename ORDER, typename ADAPTER, typename T> @@ -179,12 +198,6 @@ size_t select_strict_and_child(ADAPTER adapter, const T &children) { template <typename FLOW> struct FlowMixin { - static double estimate_of(auto adapter, const auto &children) { - return flow::estimate_of(adapter, children, FLOW(false)); - } - static double estimate_of(const auto &children) { - return estimate_of(flow::make_adapter(children), children); - } static double cost_of(auto adapter, const auto &children, bool strict) { auto my_adapter = flow::IndirectAdapter(adapter, children); auto order = flow::make_index(children.size()); @@ -200,25 +213,23 @@ class AndFlow : public FlowMixin<AndFlow> { private: double _flow; bool _strict; - bool _first; public: - AndFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()), _first(true) {} + AndFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()) {} void add(double est) noexcept { _flow *= est; - _first = false; - } - double flow() const noexcept { - return _flow; - } - bool strict() const noexcept { - return _strict && _first; - } - double estimate() const noexcept { - return _first ? 0.0 : _flow; + _strict = false; } + double flow() const noexcept { return _flow; } + bool strict() const noexcept { return _strict; } void update_cost(double &total_cost, double child_cost) noexcept { total_cost += child_cost; } + static double estimate_of(auto adapter, const auto &children) { + return flow::estimate_of_and(adapter, children); + } + static double estimate_of(const auto &children) { + return estimate_of(flow::make_adapter(children), children); + } static void sort(auto adapter, auto &children, bool strict) { flow::sort<flow::MinAndCost>(adapter, children); if (strict && children.size() > 1) { @@ -239,25 +250,24 @@ class OrFlow : public FlowMixin<OrFlow>{ private: double _flow; bool _strict; - bool _first; public: - OrFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()), _first(true) {} + OrFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()) {} void add(double est) noexcept { - _flow *= (1.0 - est); - _first = false; - } - double flow() const noexcept { - return _strict ? 1.0 : _flow; - } - bool strict() const noexcept { - return _strict; - } - double estimate() const noexcept { - return _first ? 0.0 : (1.0 - _flow); + if (!_strict) { + _flow *= (1.0 - est); + } } + double flow() const noexcept { return _flow; } + bool strict() const noexcept { return _strict; } void update_cost(double &total_cost, double child_cost) noexcept { total_cost += child_cost; } + static double estimate_of(auto adapter, const auto &children) { + return flow::estimate_of_or(adapter, children); + } + static double estimate_of(const auto &children) { + return estimate_of(flow::make_adapter(children), children); + } static void sort(auto adapter, auto &children, bool strict) { if (!strict) { flow::sort<flow::MinOrCost>(adapter, children); @@ -276,21 +286,25 @@ private: public: AndNotFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()), _first(true) {} void add(double est) noexcept { - _flow *= _first ? est : (1.0 - est); - _first = false; - } - double flow() const noexcept { - return _flow; - } - bool strict() const noexcept { - return _strict && _first; - } - double estimate() const noexcept { - return _first ? 0.0 : _flow; + if (_first) { + _flow *= est; + _strict = false; + _first = false; + } else { + _flow *= (1.0 - est); + } } + double flow() const noexcept { return _flow; } + bool strict() const noexcept { return _strict; } void update_cost(double &total_cost, double child_cost) noexcept { total_cost += child_cost; } + static double estimate_of(auto adapter, const auto &children) { + return flow::estimate_of_and_not(adapter, children); + } + static double estimate_of(const auto &children) { + return estimate_of(flow::make_adapter(children), children); + } static void sort(auto adapter, auto &children, bool) { flow::sort_partial<flow::MinOrCost>(adapter, children, 1); } @@ -299,34 +313,56 @@ public: } }; -using FlowCalc = std::function<double(double)>; - -template <typename FLOW> -FlowCalc flow_calc(InFlow in_flow) { - return [flow=FLOW(in_flow)](double est) mutable noexcept { - double next_flow = flow.flow(); - flow.add(est); - return next_flow; - }; -} - -inline FlowCalc first_flow_calc(InFlow in_flow) { - bool first = true; - double flow = in_flow.rate(); - return [first,flow](double est) mutable noexcept { - double next_flow = flow; - if (first) { - flow *= est; - first = false; - } - return next_flow; - }; -} +class RankFlow : public FlowMixin<RankFlow> { +private: + double _flow; + bool _strict; + bool _first; +public: + RankFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()), _first(true) {} + void add(double) noexcept { + _flow = 0.0; + _strict = false; + _first = false; + } + double flow() const noexcept { return _flow; } + bool strict() const noexcept { return _strict; } + void update_cost(double &total_cost, double child_cost) noexcept { + if (_first) { + total_cost += child_cost; + } + }; + static double estimate_of(auto adapter, const auto &children) { + return children.empty() ? 0.0 : adapter.estimate(children[0]); + } + static double estimate_of(const auto &children) { + return estimate_of(flow::make_adapter(children), children); + } + static void sort(auto, auto &, bool) {} + static void sort(auto &, bool) {} +}; -inline FlowCalc full_flow_calc(InFlow in_flow) { - double flow = in_flow.rate(); - return [flow](double) noexcept { return flow; }; -} +class BlenderFlow : public FlowMixin<BlenderFlow> { +private: + double _flow; + bool _strict; +public: + BlenderFlow(InFlow flow) noexcept : _flow(flow.rate()), _strict(flow.strict()) {} + void add(double) noexcept {} + double flow() const noexcept { return _flow; } + bool strict() const noexcept { return _strict; } + void update_cost(double &total_cost, double child_cost) noexcept { + total_cost = std::max(total_cost, child_cost); + }; + static double estimate_of(auto adapter, const auto &children) { + return flow::estimate_of_or(adapter, children); + } + static double estimate_of(const auto &children) { + return estimate_of(flow::make_adapter(children), children); + } + static void sort(auto, auto &, bool) {} + static void sort(auto &, bool) {} +}; // type-erased flow wrapper class AnyFlow { @@ -335,7 +371,6 @@ private: virtual void add(double est) noexcept = 0; virtual double flow() const noexcept = 0; virtual bool strict() const noexcept = 0; - virtual double estimate() const noexcept = 0; virtual void update_cost(double &total_cost, double child_cost) noexcept = 0; virtual ~API() = default; }; @@ -345,8 +380,9 @@ private: void add(double est) noexcept override { _flow.add(est); } double flow() const noexcept override { return _flow.flow(); } bool strict() const noexcept override { return _flow.strict(); } - double estimate() const noexcept override { return _flow.estimate(); } - void update_cost(double &total_cost, double child_cost) noexcept override { return _flow.update_cost(total_cost, child_cost); } + void update_cost(double &total_cost, double child_cost) noexcept override { + _flow.update_cost(total_cost, child_cost); + } ~Wrapper() = default; }; alignas(8) char _space[24]; @@ -357,8 +393,7 @@ private: using stored_type = Wrapper<FLOW>; static_assert(alignof(stored_type) <= alignof(_space)); static_assert(sizeof(stored_type) <= sizeof(_space)); - stored_type *obj = ::new (static_cast<void*>(_space)) stored_type(in_flow); - API *upcasted = obj; + API *upcasted = ::new (static_cast<void*>(_space)) stored_type(in_flow); (void) upcasted; assert(static_cast<void*>(upcasted) == static_cast<void*>(_space)); } @@ -374,8 +409,9 @@ public: void add(double est) noexcept { api().add(est); } double flow() const noexcept { return api().flow(); } bool strict() const noexcept { return api().strict(); } - double estimate() const noexcept { return api().estimate(); } - void update_cost(double &total_cost, double child_cost) noexcept { api().update_cost(total_cost, child_cost); } + void update_cost(double &total_cost, double child_cost) noexcept { + api().update_cost(total_cost, child_cost); + } }; } diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp index 9d0acc50ce5..bc8eaa98541 100644 --- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.cpp @@ -207,10 +207,10 @@ AndNotBlueprint::createFilterSearch(bool strict, FilterConstraint constraint) co } -FlowCalc -AndNotBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +AndNotBlueprint::my_flow(InFlow in_flow) const { - return flow_calc<AndNotFlow>(in_flow); + return AnyFlow::create<AndNotFlow>(in_flow); } //----------------------------------------------------------------------------- @@ -307,10 +307,10 @@ AndBlueprint::createFilterSearch(bool strict, FilterConstraint constraint) const return create_and_filter(get_children(), strict, constraint); } -FlowCalc -AndBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +AndBlueprint::my_flow(InFlow in_flow) const { - return flow_calc<AndFlow>(in_flow); + return AnyFlow::create<AndFlow>(in_flow); } //----------------------------------------------------------------------------- @@ -407,10 +407,10 @@ OrBlueprint::createFilterSearch(bool strict, FilterConstraint constraint) const return create_or_filter(get_children(), strict, constraint); } -FlowCalc -OrBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +OrBlueprint::my_flow(InFlow in_flow) const { - return flow_calc<OrFlow>(in_flow); + return AnyFlow::create<OrFlow>(in_flow); } uint8_t @@ -425,10 +425,10 @@ OrBlueprint::calculate_cost_tier() const //----------------------------------------------------------------------------- -FlowCalc -WeakAndBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +WeakAndBlueprint::my_flow(InFlow in_flow) const { - return flow_calc<OrFlow>(in_flow); + return AnyFlow::create<OrFlow>(in_flow); } WeakAndBlueprint::~WeakAndBlueprint() = default; @@ -502,10 +502,10 @@ WeakAndBlueprint::createFilterSearch(bool strict, FilterConstraint constraint) c //----------------------------------------------------------------------------- -FlowCalc -NearBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +NearBlueprint::my_flow(InFlow in_flow) const { - return flow_calc<AndFlow>(in_flow); + return AnyFlow::create<AndFlow>(in_flow); } FlowStats @@ -573,10 +573,10 @@ NearBlueprint::createFilterSearch(bool strict, FilterConstraint constraint) cons //----------------------------------------------------------------------------- -FlowCalc -ONearBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +ONearBlueprint::my_flow(InFlow in_flow) const { - return flow_calc<AndFlow>(in_flow); + return AnyFlow::create<AndFlow>(in_flow); } FlowStats @@ -734,18 +734,18 @@ RankBlueprint::createFilterSearch(bool strict, FilterConstraint constraint) cons return create_first_child_filter(get_children(), strict, constraint); } -FlowCalc -RankBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +RankBlueprint::my_flow(InFlow in_flow) const { - return first_flow_calc(in_flow); + return AnyFlow::create<RankFlow>(in_flow); } //----------------------------------------------------------------------------- -FlowCalc -SourceBlenderBlueprint::make_flow_calc(InFlow in_flow) const +AnyFlow +SourceBlenderBlueprint::my_flow(InFlow in_flow) const { - return full_flow_calc(in_flow); + return AnyFlow::create<BlenderFlow>(in_flow); } SourceBlenderBlueprint::SourceBlenderBlueprint(const ISourceSelector &selector) noexcept diff --git a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h index 028898d3f47..e0f4be4be06 100644 --- a/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h +++ b/searchlib/src/vespa/searchlib/queryeval/intermediate_blueprints.h @@ -29,7 +29,7 @@ public: SearchIterator::UP createFilterSearch(bool strict, FilterConstraint constraint) const override; private: - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; uint8_t calculate_cost_tier() const override { return (childCnt() > 0) ? get_children()[0]->getState().cost_tier() : State::COST_TIER_NORMAL; } @@ -57,7 +57,7 @@ public: SearchIterator::UP createFilterSearch(bool strict, FilterConstraint constraint) const override; private: - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; }; //----------------------------------------------------------------------------- @@ -82,7 +82,7 @@ public: SearchIterator::UP createFilterSearch(bool strict, FilterConstraint constraint) const override; private: - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; uint8_t calculate_cost_tier() const override; }; @@ -94,7 +94,7 @@ private: uint32_t _n; std::vector<uint32_t> _weights; - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; public: FlowStats calculate_flow_stats(uint32_t docid_limit) const final; HitEstimate combine(const std::vector<HitEstimate> &data) const override; @@ -125,7 +125,7 @@ class NearBlueprint : public IntermediateBlueprint private: uint32_t _window; - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; public: FlowStats calculate_flow_stats(uint32_t docid_limit) const final; HitEstimate combine(const std::vector<HitEstimate> &data) const override; @@ -148,7 +148,7 @@ class ONearBlueprint : public IntermediateBlueprint private: uint32_t _window; - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; public: FlowStats calculate_flow_stats(uint32_t docid_limit) const final; HitEstimate combine(const std::vector<HitEstimate> &data) const override; @@ -186,7 +186,7 @@ public: return (childCnt() > 0) ? get_children()[0]->getState().cost_tier() : State::COST_TIER_NORMAL; } private: - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; }; //----------------------------------------------------------------------------- @@ -196,7 +196,7 @@ class SourceBlenderBlueprint final : public IntermediateBlueprint private: const ISourceSelector &_selector; - FlowCalc make_flow_calc(InFlow in_flow) const override; + AnyFlow my_flow(InFlow in_flow) const override; public: explicit SourceBlenderBlueprint(const ISourceSelector &selector) noexcept; ~SourceBlenderBlueprint() override; |