Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Rewrite lookup index selection implementation #1188

Merged
merged 42 commits into from
Jul 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ce21fd4
Add specified index scan nodes
yixinglu Jun 17, 2021
84a0f2f
Refactor lookup validator
yixinglu Jun 21, 2021
c3b4445
Fix getcontext in validator
yixinglu Jun 21, 2021
83f319e
Refactor index scan plan node
yixinglu Jun 22, 2021
2f6f692
construct IndexScan plan node
yixinglu Jun 22, 2021
11715ba
Add opt rule for indexscan and filter
yixinglu Jun 22, 2021
732c466
Select index
yixinglu Jun 28, 2021
9f1698b
Fix file edge scan rule
yixinglu Jun 29, 2021
7cef1ac
Fix crash
yixinglu Jun 29, 2021
b9d4a85
Add lookup tests
yixinglu Jun 29, 2021
ef3fb81
Fix bug
yixinglu Jun 29, 2021
1a38bc6
Resolve conflicts
yixinglu Jun 30, 2021
7da9462
Cleanup
yixinglu Jun 30, 2021
4836ccf
Rename priority to score
yixinglu Jun 30, 2021
3f8fb95
Refactor tck test cases
yixinglu Jun 30, 2021
a262893
More cases
yixinglu Jun 30, 2021
75cbbf1
Cleanup
yixinglu Jun 30, 2021
e749a9f
Fix logicalor and lookup on tag and edge
yixinglu Jun 30, 2021
d1f4790
fix nullptr initialize bug
yixinglu Jun 30, 2021
0ba10c4
Fix invalid column name
yixinglu Jun 30, 2021
77884b8
Fix bug
yixinglu Jun 30, 2021
cecc2b5
Fix lookup column errors
yixinglu Jun 30, 2021
9bd5e4f
Add more or expr cases
yixinglu Jun 30, 2021
eede6b9
Limit IndexScanRule usage
yixinglu Jul 1, 2021
8f96cc9
drop space
yixinglu Jul 1, 2021
dfbeb93
Fix IndexFullScanRule
yixinglu Jul 1, 2021
cdd9fce
Fix multiple range error
yixinglu Jul 1, 2021
74403f6
Fix failed tests
yixinglu Jul 1, 2021
1ab30e3
Fix comment
yixinglu Jul 1, 2021
e31b812
Cleanup and comment
yixinglu Jul 2, 2021
80cf985
more comments for logical or expression
yixinglu Jul 2, 2021
40cd187
Fix lookup validator unit tests
yixinglu Jul 2, 2021
286a62d
Fix debug option
yixinglu Jul 2, 2021
11f61cc
cleanup Makefile
yixinglu Jul 2, 2021
bbc5c96
Fix tck cases about examples usage
yixinglu Jul 2, 2021
0e4abaf
improve slow query test cases
yixinglu Jul 2, 2021
60174ff
format and fix optrule match
yixinglu Jul 2, 2021
6727b8a
cleanup
yixinglu Jul 2, 2021
014fb2f
Define extern string const values
yixinglu Jul 2, 2021
bf55aac
Fix reclaim secs
yixinglu Jul 2, 2021
dd387b9
Merge branch 'master' into refactor-lookup-index
yixinglu Jul 2, 2021
e244e46
Merge branch 'master' into refactor-lookup-index
CPWstatic Jul 3, 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
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ jobs:
- name: Pytest
run: |
make up
make RM_DIR=false J=${{ steps.cmake.outputs.j }} test
make RM_DIR=false DEBUG=false J=${{ steps.cmake.outputs.j }} test
make down
working-directory: tests/
timeout-minutes: 15
- name: TCK
run: |
make up
make RM_DIR=false J=${{ steps.cmake.outputs.j }} tck
make RM_DIR=false DEBUG=false J=${{ steps.cmake.outputs.j }} tck
make down
working-directory: tests/
timeout-minutes: 20
timeout-minutes: 25
- name: Sanitizer
if: ${{ always() }}
run: |
Expand Down
3 changes: 3 additions & 0 deletions src/context/ast/AstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@

namespace nebula {
namespace graph {

struct AstContext {
QueryContext* qctx;
Sentence* sentence;
SpaceInfo space;
};

} // namespace graph
} // namespace nebula

#endif // CONTEXT_ASTCONTEXT_H_
10 changes: 10 additions & 0 deletions src/context/ast/QueryAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ struct GoContext final : AstContext {
std::string inputVarName;
};

struct LookupContext final : public AstContext {
bool isEdge{false};
bool dedup{false};
bool isEmptyResultSet{false};
int32_t schemaId{-1};
int32_t limit{-1};
Expression* filter{nullptr};
// order by
};

} // namespace graph
} // namespace nebula
#endif // CONTEXT_AST_QUERYASTCONTEXT_H_
8 changes: 7 additions & 1 deletion src/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
case PlanNode::Kind::kUnwind: {
return pool->add(new UnwindExecutor(node, qctx));
}
case PlanNode::Kind::kIndexScan: {
case PlanNode::Kind::kIndexScan:
case PlanNode::Kind::kEdgeIndexFullScan:
case PlanNode::Kind::kEdgeIndexPrefixScan:
case PlanNode::Kind::kEdgeIndexRangeScan:
case PlanNode::Kind::kTagIndexFullScan:
case PlanNode::Kind::kTagIndexPrefixScan:
case PlanNode::Kind::kTagIndexRangeScan: {
return pool->add(new IndexScanExecutor(node, qctx));
}
case PlanNode::Kind::kStart: {
Expand Down
4 changes: 2 additions & 2 deletions src/executor/query/IndexScanExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ folly::Future<Status> IndexScanExecutor::indexScan() {
return finish(ResultBuilder().value(Value(std::move(dataSet))).finish());
}
return storageClient->lookupIndex(lookup->space(),
*lookup->queryContext(),
lookup->queryContext(),
lookup->isEdge(),
lookup->schemaId(),
*lookup->returnColumns())
lookup->returnColumns())
.via(runner())
.thenValue([this](StorageRpcResponse<LookupIndexResp> &&rpcResp) {
return handleResp(std::move(rpcResp));
Expand Down
8 changes: 8 additions & 0 deletions src/optimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ nebula_add_library(
rule/PushFilterDownAggregateRule.cpp
rule/PushFilterDownProjectRule.cpp
rule/PushFilterDownLeftJoinRule.cpp
rule/PushFilterDownEdgeIndexScanRule.cpp
rule/PushFilterDownTagIndexScanRule.cpp
rule/UnionAllIndexScanBaseRule.cpp
rule/UnionAllTagIndexScanRule.cpp
rule/UnionAllEdgeIndexScanRule.cpp
rule/IndexFullScanBaseRule.cpp
rule/TagIndexFullScanRule.cpp
rule/EdgeIndexFullScanRule.cpp
)

nebula_add_subdirectory(test)
17 changes: 17 additions & 0 deletions src/optimizer/OptRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@
#include "optimizer/OptGroup.h"
#include "planner/plan/PlanNode.h"

using nebula::graph::PlanNode;

namespace nebula {
namespace opt {

const PlanNode *MatchedResult::planNode(const std::vector<int32_t> &pos) const {
if (pos.empty()) {
return DCHECK_NOTNULL(node)->node();
}

DCHECK_EQ(pos[0], 0);

const MatchedResult *result = this;
for (size_t i = 1; i < pos.size(); ++i) {
DCHECK_LT(pos[i], result->dependencies.size());
result = &result->dependencies[pos[i]];
}
return DCHECK_NOTNULL(result->node)->node();
}

Pattern Pattern::create(graph::PlanNode::Kind kind, std::initializer_list<Pattern> patterns) {
Pattern pattern;
pattern.kind_ = kind;
Expand Down
11 changes: 11 additions & 0 deletions src/optimizer/OptRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace nebula {

namespace graph {
class QueryContext;
class PlanNode;
} // namespace graph

namespace opt {
Expand All @@ -30,6 +31,16 @@ class OptGroup;
struct MatchedResult {
const OptGroupNode *node{nullptr};
std::vector<MatchedResult> dependencies;

// params | plan node
// -------------+------------
// {} | this->node
// {0} | this->node
// {1} | error
// {0, 1} | this->dependencies[1]
// {0, 1, 0} | this->dependencies[1].dependencies[0]
// {0, 1, 0, 1} | this->dependencies[1].dependencies[0].dependencies[1]
const graph::PlanNode *planNode(const std::vector<int32_t> &pos = {}) const;
};

class Pattern final {
Expand Down
Loading