aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-07-24 09:50:00 +0200
committerGitHub <noreply@github.com>2018-07-24 09:50:00 +0200
commit5e09a340eb2571ef9c9a5d7df7b38838821cd697 (patch)
tree4b396e12f1145bef4f4bff99a83b7393bae38994
parentf10eaedc0694389f1a7fa9c2e1657148569f18de (diff)
parent9933dd135928b850267f78c2250be35a7969f0d6 (diff)
Merge pull request #6453 from vespa-engine/balder/recurse-down-to-correct-place
Move the whitelist down through AndNot and Rank to the last one and '…
-rw-r--r--searchcore/src/tests/proton/matching/query_test.cpp17
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/query.cpp13
2 files changed, 24 insertions, 6 deletions
diff --git a/searchcore/src/tests/proton/matching/query_test.cpp b/searchcore/src/tests/proton/matching/query_test.cpp
index b80fba86796..82aab72068d 100644
--- a/searchcore/src/tests/proton/matching/query_test.cpp
+++ b/searchcore/src/tests/proton/matching/query_test.cpp
@@ -887,10 +887,11 @@ Test::requireThatWhiteListBlueprintCanBeUsed()
EXPECT_EQUAL(exp, act);
}
-template<typename T>
+template<typename T1, typename T2>
void verifyThatRankBlueprintAndAndNotStaysOnTopAfterWhiteListing(QueryBuilder<ProtonNodeTypes> & builder) {
builder.addStringTerm("foo", field, field_id, string_weight);
builder.addStringTerm("bar", field, field_id, string_weight);
+ builder.addStringTerm("baz", field, field_id, string_weight);
std::string stackDump = StackDumpCreator::create(*builder.build());
Query query;
query.buildTree(stackDump, "", ViewResolver(), plain_index_env);
@@ -904,27 +905,33 @@ void verifyThatRankBlueprintAndAndNotStaysOnTopAfterWhiteListing(QueryBuilder<Pr
FakeRequestContext requestContext;
MatchDataLayout mdl;
query.reserveHandles(requestContext, context, mdl);
- const IntermediateBlueprint * root = dynamic_cast<const T *>(query.peekRoot());
+ const IntermediateBlueprint * root = dynamic_cast<const T1 *>(query.peekRoot());
ASSERT_TRUE(root != nullptr);
EXPECT_EQUAL(2u, root->childCnt());
- const AndBlueprint * first = dynamic_cast<const AndBlueprint *>(&root->getChild(0));
+ const IntermediateBlueprint * second = dynamic_cast<const T2 *>(&root->getChild(0));
+ ASSERT_TRUE(second != nullptr);
+ EXPECT_EQUAL(2u, second->childCnt());
+ const AndBlueprint * first = dynamic_cast<const AndBlueprint *>(&second->getChild(0));
ASSERT_TRUE(first != nullptr);
EXPECT_EQUAL(2u, first->childCnt());
EXPECT_TRUE(dynamic_cast<const SourceBlenderBlueprint *>(&first->getChild(0)));
EXPECT_TRUE(dynamic_cast<const SimpleBlueprint *>(&first->getChild(1)));
+ EXPECT_TRUE(dynamic_cast<const SourceBlenderBlueprint *>(&second->getChild(1)));
EXPECT_TRUE(dynamic_cast<const SourceBlenderBlueprint *>(&root->getChild(1)));
}
void Test::requireThatRankBlueprintStaysOnTopAfterWhiteListing() {
QueryBuilder<ProtonNodeTypes> builder;
builder.addRank(2);
- verifyThatRankBlueprintAndAndNotStaysOnTopAfterWhiteListing<RankBlueprint>(builder);
+ builder.addAndNot(2);
+ verifyThatRankBlueprintAndAndNotStaysOnTopAfterWhiteListing<RankBlueprint, AndNotBlueprint>(builder);
}
void Test::requireThatAndNotBlueprintStaysOnTopAfterWhiteListing() {
QueryBuilder<ProtonNodeTypes> builder;
builder.addAndNot(2);
- verifyThatRankBlueprintAndAndNotStaysOnTopAfterWhiteListing<AndNotBlueprint>(builder);
+ builder.addRank(2);
+ verifyThatRankBlueprintAndAndNotStaysOnTopAfterWhiteListing<AndNotBlueprint, RankBlueprint>(builder);
}
diff --git a/searchcore/src/vespa/searchcore/proton/matching/query.cpp b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
index 1de664fe6ab..e550ad8cad7 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/query.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/query.cpp
@@ -86,6 +86,17 @@ asRankOrAndNot(Blueprint * blueprint) {
return rankOrAndNot;
}
+IntermediateBlueprint *
+lastConsequtiveRankOrAndNot(Blueprint * blueprint) {
+ IntermediateBlueprint * prev = nullptr;
+ IntermediateBlueprint * curr = asRankOrAndNot(blueprint);
+ while (curr != nullptr) {
+ prev = curr;
+ curr = asRankOrAndNot(&curr->getChild(0));
+ }
+ return prev;
+}
+
} // namespace
Query::Query() = default;
@@ -139,7 +150,7 @@ Query::reserveHandles(const IRequestContext & requestContext, ISearchContext &co
LOG(debug, "original blueprint:\n%s\n", _blueprint->asString().c_str());
if (_whiteListBlueprint) {
auto andBlueprint = std::make_unique<AndBlueprint>();
- IntermediateBlueprint * rankOrAndNot = asRankOrAndNot(_blueprint.get());
+ IntermediateBlueprint * rankOrAndNot = lastConsequtiveRankOrAndNot(_blueprint.get());
if (rankOrAndNot != nullptr) {
(*andBlueprint)
.addChild(rankOrAndNot->removeChild(0))