diff options
author | Geir Storli <geirst@yahooinc.com> | 2024-02-05 10:48:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 10:48:34 +0100 |
commit | 3da723264949a92244565b962c2a4f773203d1e8 (patch) | |
tree | 776dc51eb9762eb6acd9e0ca579ba0fa38177390 /searchlib/src/tests | |
parent | 2a7f13b47eb2ddb18e4a98d94b8e3c1d41e89bbe (diff) | |
parent | 4bd0028bc7ef17604cb11167e58273aa13c0f954 (diff) |
Merge pull request #30140 from vespa-engine/havardpe/re-wire-flow-stats-calculation
re-wire flow stats in blueprints
Diffstat (limited to 'searchlib/src/tests')
3 files changed, 15 insertions, 14 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp index 90452f1d12b..51164427690 100644 --- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp @@ -23,14 +23,10 @@ class MyOr : public IntermediateBlueprint { private: public: - double calculate_relative_estimate() const final { - return OrFlow::estimate_of(get_children()); - } - double calculate_cost() const final { - return OrFlow::cost_of(get_children(), false); - } - double calculate_strict_cost() const final { - return OrFlow::cost_of(get_children(), true); + FlowStats calculate_flow_stats(uint32_t) const final { + return {OrFlow::estimate_of(get_children()), + OrFlow::cost_of(get_children(), false), + OrFlow::cost_of(get_children(), true)}; } HitEstimate combine(const std::vector<HitEstimate> &data) const override { return max(data); @@ -798,7 +794,7 @@ TEST("requireThatDocIdLimitInjectionWorks") TEST("Control object sizes") { EXPECT_EQUAL(32u, sizeof(Blueprint::State)); EXPECT_EQUAL(56u, sizeof(Blueprint)); - EXPECT_EQUAL(96u, sizeof(LeafBlueprint)); + EXPECT_EQUAL(88u, sizeof(LeafBlueprint)); } TEST_MAIN() { diff --git a/searchlib/src/tests/queryeval/blueprint/mysearch.h b/searchlib/src/tests/queryeval/blueprint/mysearch.h index 6eb27364c2b..79c9885bb7d 100644 --- a/searchlib/src/tests/queryeval/blueprint/mysearch.h +++ b/searchlib/src/tests/queryeval/blueprint/mysearch.h @@ -117,8 +117,15 @@ public: MyLeaf() : SimpleLeafBlueprint() {} MyLeaf(FieldSpecBaseList fields) : SimpleLeafBlueprint(std::move(fields)) {} void set_cost(double value) noexcept { _cost = value; } - double calculate_cost() const override { return _cost; } - + FlowStats calculate_flow_stats(uint32_t docid_limit) const override { + double rel_est = abs_to_rel_est(getState().estimate().estHits, docid_limit); + if (rel_est > 0.9) { + return {0.5, _cost, _cost}; + } else { + return {rel_est, _cost, _cost * rel_est}; + } + } + MyLeaf &estimate(uint32_t hits, bool empty = false) { setEstimate(HitEstimate(hits, empty)); return *this; diff --git a/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp b/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp index 4fc8922b9a3..ca450c6d712 100644 --- a/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp +++ b/searchlib/src/tests/queryeval/filter_search/filter_search_test.cpp @@ -47,9 +47,7 @@ concept ChildCollector = requires(T a, std::unique_ptr<Blueprint> bp) { // inherit Blueprint to capture the default filter factory struct DefaultBlueprint : Blueprint { - double calculate_relative_estimate() const override { abort(); } - double calculate_cost() const override { abort(); } - double calculate_strict_cost() const override { abort(); } + FlowStats calculate_flow_stats(uint32_t) const override { abort(); } void optimize(Blueprint* &, OptimizePass) override { abort(); } void sort(bool, bool) override { abort(); } const State &getState() const override { abort(); } |