8000 Feature/search 213 optimize levenshtein startswith by Dronplane · Pull Request #14744 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Feature/search 213 optimize levenshtein startswith #14744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Sep 10, 2021
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
64944e5
group conjunction nodes
Dronplane Sep 3, 2021
c6d0ab3
Merge branch 'devel' into feature/SEARCH-213-Optimize-Levenshtein-sta…
Dronplane Sep 6, 2021
4664cc4
wip
Dronplane Sep 6, 2021
b545d56
tests
Dronplane Sep 6, 2021
b026fa4
tests
Dronplane Sep 7, 2021
9dfe7b9
tests
Dronplane Sep 7, 2021
0abc986
Merge branch 'devel' into feature/SEARCH-213-Optimize-Levenshtein-sta…
Dronplane Sep 7, 2021
5b8eda2
moar tests
Dronplane Sep 7, 2021
6f11b5d
add option to explicitly block merging
Dronplane Sep 7, 2021
337cd90
moar corner cases
Dronplane Sep 8, 2021
17ea36a
empty case optimization
Dronplane Sep 8, 2021
55c038c
optimization
Dronplane Sep 8, 2021
229c972
cleanup
Dronplane Sep 8, 2021
f5d8684
fix startsWith boost
Dronplane Sep 8, 2021
af37ee0
cleanup
Dronplane Sep 8, 2021
eae7ebb
wip
Dronplane Sep 8, 2021
26386d4
wip
Dronplane Sep 8, 2021
37be60d
comments
Dronplane Sep 8, 2021
bcd2093
add node serialization tests
Dronplane Sep 8, 2021
d649660
Update arangod/IResearch/IResearchFilterFactory.cpp
Dronplane Sep 9, 2021
4cd8331
adress review comments
Dronplane Sep 9, 2021
a969139
address review comments
Dronplane Sep 9, 2021
0e6b6cf
add js test
Dronplane Sep 9, 2021
0c6d9ca
adress review comments
Dronplane Sep 9, 2021
09c678c
Update CHANGELOG
Dronplane Sep 9, 2021
1708a0a
Merge branch 'devel' into feature/SEARCH-213-Optimize-Levenshtein-sta…
Dronplane Sep 9, 2021
d234738
Merge branch 'devel' into feature/SEARCH-213-Optimize-Levenshtein-sta…
Dronplane Sep 10, 2021
f89293e
None -> NONE renaming
Dronplane Sep 10, 2021
340087d
Merge branch 'feature/SEARCH-213-Optimize-Levenshtein-startswith' of …
Dronplane Sep 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
group conjunction nodes
  • Loading branch information
Dronplane committed Sep 3, 2021
commit 64944e5590b304da9c99100d8f966018dbe1267c
47 changes: 47 additions & 0 deletions arangod/Aql/IResearchViewOptimizerRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,52 @@ inline IResearchViewStoredValues const& storedValues(arangodb::LogicalView const
return viewImpl.storedValues();
}

/// @brief Moves all LEVENSHTEIN_MATCH before STRATS_WITH in every AND nodes
/// to make it possible later optimize out STARTS_WITH covered by LEVENSHTEIN_MATCH
/// @param condition SEARCH condition node
/// @param plan current query plan
void groupStartsAndLevenshtein(arangodb::aql::AstNode& condition, ExecutionPlan& plan) {
auto numMembers = condition.numMembers();
//arangodb::iresearch::QueryContext queryContextForOptimization;
for (size_t memberIdx = 0; memberIdx < numMembers; ++memberIdx) {
auto current = condition.getMemberUnchecked(memberIdx);
TRI_ASSERT(current);
if (current->type == arangodb::aql::AstNodeType::NODE_TYPE_OPERATOR_NARY_AND) {
auto numAndMembers = current->numMembers();
if (numAndMembers > 1) {
size_t movePoint = numAndMembers -1;
while (movePoint != 0 &&
current->getMemberUnchecked(movePoint)->type == arangodb::aql::AstNodeType::NODE_TYPE_FCALL &&
arangodb::iresearch::getFuncName(*current->getMemberUnchecked(movePoint)) == "STARTS_WITH") {
--movePoint;
}
for (size_t andMemberIdx = 0; andMemberIdx < movePoint; ++andMemberIdx) {
auto andMember = current->getMemberUnchecked(andMemberIdx);
if (andMember->type == arangodb::aql::AstNodeType::NODE_TYPE_FCALL) {
if (arangodb::iresearch::getFuncName(*andMember) == "STARTS_WITH") {
auto tmp = current->getMemberUnchecked(movePoint);
current->changeMember(movePoint, andMember);
current->changeMember(andMemberIdx, tmp);
while (movePoint > andMemberIdx &&
current->getMemberUnchecked(movePoint)->type == arangodb::aql::AstNodeType::NODE_TYPE_FCALL &&
arangodb::iresearch::getFuncName(*current->getMemberUnchecked(movePoint)) == "STARTS_WITH") {
--movePoint;
}
}
} else {
groupStartsAndLevenshtein(*andMember, plan);
}
}
} else {
groupStartsAndLevenshtein(*current, plan);
}
} else {
groupStartsAndLevenshtein(*current, plan);
}
}

}

bool addView(arangodb::LogicalView const& view, arangodb::aql::QueryContext& query) {
auto& collections = query.collections();

Expand Down Expand Up @@ -132,6 +178,7 @@ bool optimizeSearchCondition(IResearchViewNode& viewNode, arangodb::aql::QueryCo

// check filter condition if present
if (searchCondition.root()) {
groupStartsAndLevenshtein(*searchCondition.root(), plan);
auto filterCreated = FilterFactory::filter(
nullptr,
{ &query.trxForOptimization(), nullptr, nullptr, nullptr, nullptr, &viewNode.outVariable() },
Expand Down
0