summaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2024-01-19 14:34:54 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2024-01-22 14:53:33 +0000
commit56da1f042e9d2d545267c33242a51bf94a5fd12b (patch)
treedec504966cd31b918fb49a46174f7e65f59038c9 /searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
parentccda952db487445f3522eecbcbfee4a6f6a90c32 (diff)
wire in strict flow analysis and strict-aware sorting
strict_cost added to all blueprints separate top-down sort step after optimize move relative estimate out of blueprint state optimize all children; to calculate flow stats leaf defaults: matching>0.9: est: 0.5, cost: 1.0, strict_cost: 1.0 matching<=0.9: est: rel_est, cost: 1.0, strict_cost: rel_est
Diffstat (limited to 'searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp')
-rw-r--r--searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp48
1 files changed, 29 insertions, 19 deletions
diff --git a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
index bbd2744119a..90452f1d12b 100644
--- a/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
+++ b/searchlib/src/tests/queryeval/blueprint/blueprint_test.cpp
@@ -23,12 +23,15 @@ class MyOr : public IntermediateBlueprint
{
private:
public:
- double calculate_cost() const final {
- return OrFlow::cost_of(get_children());
- }
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);
+ }
HitEstimate combine(const std::vector<HitEstimate> &data) const override {
return max(data);
}
@@ -37,7 +40,7 @@ public:
return mixChildrenFields();
}
- void sort(Children &children, bool) const override {
+ void sort(Children &children, bool, bool) const override {
std::sort(children.begin(), children.end(), TieredGreaterEstimate());
}
@@ -446,7 +449,7 @@ TEST_F("testChildAndNotCollapsing", Fixture)
);
TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted->setDocIdLimit(1000);
- unsorted = Blueprint::optimize(std::move(unsorted), true);
+ unsorted = Blueprint::optimize_and_sort(std::move(unsorted), true, true);
TEST_DO(f.check_equal(*sorted, *unsorted));
}
@@ -486,7 +489,7 @@ TEST_F("testChildAndCollapsing", Fixture)
TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted->setDocIdLimit(1000);
- unsorted = Blueprint::optimize(std::move(unsorted), true);
+ unsorted = Blueprint::optimize_and_sort(std::move(unsorted), true, true);
TEST_DO(f.check_equal(*sorted, *unsorted));
}
@@ -525,7 +528,10 @@ TEST_F("testChildOrCollapsing", Fixture)
);
TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted->setDocIdLimit(1000);
- unsorted = Blueprint::optimize(std::move(unsorted), true);
+ // we sort non-strict here since the default costs of 1/est for
+ // non-strict/strict leaf iterators makes the order of iterators
+ // under a strict OR irrelevant.
+ unsorted = Blueprint::optimize_and_sort(std::move(unsorted), false, true);
TEST_DO(f.check_equal(*sorted, *unsorted));
}
@@ -569,7 +575,7 @@ TEST_F("testChildSorting", Fixture)
TEST_DO(f.check_not_equal(*sorted, *unsorted));
unsorted->setDocIdLimit(1000);
- unsorted = Blueprint::optimize(std::move(unsorted), true);
+ unsorted = Blueprint::optimize_and_sort(std::move(unsorted), true, true);
TEST_DO(f.check_equal(*sorted, *unsorted));
}
@@ -650,12 +656,13 @@ getExpectedBlueprint()
" estimate: HitEstimate {\n"
" empty: false\n"
" estHits: 9\n"
- " relative_estimate: 0.5\n"
" cost_tier: 1\n"
" tree_size: 2\n"
" allow_termwise_eval: false\n"
" }\n"
- " cost: 1\n"
+ " relative_estimate: 0\n"
+ " cost: 0\n"
+ " strict_cost: 0\n"
" sourceId: 4294967295\n"
" docid_limit: 0\n"
" children: std::vector {\n"
@@ -671,12 +678,13 @@ getExpectedBlueprint()
" estimate: HitEstimate {\n"
" empty: false\n"
" estHits: 9\n"
- " relative_estimate: 0.5\n"
" cost_tier: 1\n"
" tree_size: 1\n"
" allow_termwise_eval: true\n"
" }\n"
- " cost: 1\n"
+ " relative_estimate: 0\n"
+ " cost: 0\n"
+ " strict_cost: 0\n"
" sourceId: 4294967295\n"
" docid_limit: 0\n"
" }\n"
@@ -702,12 +710,13 @@ getExpectedSlimeBlueprint() {
" '[type]': 'HitEstimate',"
" empty: false,"
" estHits: 9,"
- " relative_estimate: 0.5,"
" cost_tier: 1,"
" tree_size: 2,"
" allow_termwise_eval: false"
" },"
- " cost: 1.0,"
+ " relative_estimate: 0.0,"
+ " cost: 0.0,"
+ " strict_cost: 0.0,"
" sourceId: 4294967295,"
" docid_limit: 0,"
" children: {"
@@ -728,12 +737,13 @@ getExpectedSlimeBlueprint() {
" '[type]': 'HitEstimate',"
" empty: false,"
" estHits: 9,"
- " relative_estimate: 0.5,"
" cost_tier: 1,"
" tree_size: 1,"
" allow_termwise_eval: true"
" },"
- " cost: 1.0,"
+ " relative_estimate: 0.0,"
+ " cost: 0.0,"
+ " strict_cost: 0.0,"
" sourceId: 4294967295,"
" docid_limit: 0"
" }"
@@ -786,9 +796,9 @@ TEST("requireThatDocIdLimitInjectionWorks")
}
TEST("Control object sizes") {
- EXPECT_EQUAL(40u, sizeof(Blueprint::State));
- EXPECT_EQUAL(40u, sizeof(Blueprint));
- EXPECT_EQUAL(80u, sizeof(LeafBlueprint));
+ EXPECT_EQUAL(32u, sizeof(Blueprint::State));
+ EXPECT_EQUAL(56u, sizeof(Blueprint));
+ EXPECT_EQUAL(96u, sizeof(LeafBlueprint));
}
TEST_MAIN() {