Skip to content

Commit

Permalink
show tag/edge index status (vesoft-inc#389)
Browse files Browse the repository at this point in the history
* show tag/edge index status

* fix CI find_in_rows bug

* remove unused var

* Ignore nebula-python

* Cleanup workspace

* Cleanup before checkout

* rm -rf *
  • Loading branch information
jievince authored Nov 25, 2020
1 parent d2c043e commit eac0742
Show file tree
Hide file tree
Showing 28 changed files with 434 additions and 149 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ jobs:
- /tmp/ccache/nebula-graph/${{ matrix.os }}-${{ matrix.compiler }}:/tmp/ccache/nebula-graph/${{ matrix.os }}-${{ matrix.compiler }}
options: --mount type=tmpfs,destination=/tmp/ccache/nebula-graph,tmpfs-size=1073741824 --cap-add=SYS_PTRACE
steps:
- name: Cleanup
if: ${{ always() }}
run: rm -rf *
- uses: actions/checkout@v2
- name: Checkout nebula-python
uses: actions/checkout@v2
Expand Down Expand Up @@ -136,6 +139,3 @@ jobs:
with:
name: ${{ matrix.os }}-${{ matrix.compiler }}-nebula-test-logs
path: build/server_*/logs/
- name: Cleanup
if: ${{ always() }}
run: rm -rf build modules && rm -rf /tmp/nebula-*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target/
cluster.id
pids/
modules/
nebula-python/

# IDE
.idea/
Expand Down
6 changes: 6 additions & 0 deletions src/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
case PlanNode::Kind::kShowEdgeIndexes: {
return pool->add(new ShowEdgeIndexesExecutor(node, qctx));
}
case PlanNode::Kind::kShowTagIndexStatus: {
return pool->add(new ShowTagIndexStatusExecutor(node, qctx));
}
case PlanNode::Kind::kShowEdgeIndexStatus: {
return pool->add(new ShowEdgeIndexStatusExecutor(node, qctx));
}
case PlanNode::Kind::kInsertVertices: {
return pool->add(new InsertVerticesExecutor(node, qctx));
}
Expand Down
37 changes: 3 additions & 34 deletions src/executor/admin/SubmitJobExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,10 @@ folly::Future<Status> SubmitJobExecutor::execute() {

auto *sjNode = asNode<SubmitJob>(node());
auto jobOp = sjNode->jobOp();
std::vector<std::string> jobArguments;
auto cmd = sjNode->cmd();
auto params = sjNode->params();

meta::cpp2::AdminCmd cmd = meta::cpp2::AdminCmd::UNKNOWN;
if (jobOp == meta::cpp2::AdminJobOp::ADD) {
auto spaceName = qctx()->rctx()->session()->space().name;
jobArguments.emplace_back(std::move(spaceName));
auto& params = sjNode->params();
if (params[0] == "compact") {
cmd = meta::cpp2::AdminCmd::COMPACT;
} else if (params[0] == "flush") {
cmd = meta::cpp2::AdminCmd::FLUSH;
} else if (params[0] == "rebuild") {
if (params[1] == "tag") {
cmd = meta::cpp2::AdminCmd::REBUILD_TAG_INDEX;
jobArguments.emplace_back(params[3]);
} else if (params[1] == "edge") {
cmd = meta::cpp2::AdminCmd::REBUILD_EDGE_INDEX;
jobArguments.emplace_back(params[3]);
} else {
LOG(ERROR) << "Unknown job command rebuild " << params[1];
return Status::Error("Unknown job command rebuild %s", params[1].c_str());
}
} else if (params[0] == "stats") {
cmd = meta::cpp2::AdminCmd::STATS;
} else {
LOG(ERROR) << "Unknown job command " << params[0].c_str();
return Status::Error("Unknown job command %s", params[0].c_str());
}
} else if (jobOp == meta::cpp2::AdminJobOp::SHOW || jobOp == meta::cpp2::AdminJobOp::STOP) {
auto& params = sjNode->params();
DCHECK_GT(params.size(), 0UL);
jobArguments.emplace_back(params[0]);
}

return qctx()->getMetaClient()->submitJob(jobOp, cmd, jobArguments)
return qctx()->getMetaClient()->submitJob(jobOp, cmd, params)
.via(runner())
.then([jobOp, this](StatusOr<meta::cpp2::AdminJobResult> &&resp) {
SCOPED_TIMER(&execTime_);
Expand Down
29 changes: 29 additions & 0 deletions src/executor/maintain/EdgeIndexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,34 @@ folly::Future<Status> ShowEdgeIndexesExecutor::execute() {
});
}

folly::Future<Status> ShowEdgeIndexStatusExecutor::execute() {
SCOPED_TIMER(&execTime_);

auto spaceId = qctx()->rctx()->session()->space().id;
return qctx()->getMetaClient()->listEdgeIndexStatus(spaceId).via(runner()).then(
[this, spaceId](StatusOr<std::vector<meta::cpp2::IndexStatus>> resp) {
if (!resp.ok()) {
LOG(ERROR) << "SpaceId: " << spaceId << ", Show edge index status failed"
<< resp.status();
return resp.status();
}

auto indexStatuses = std::move(resp).value();

DataSet dataSet;
dataSet.colNames = {"Name", "Index Status"};
for (auto &indexStatus : indexStatuses) {
Row row;
row.values.emplace_back(std::move(indexStatus.get_name()));
row.values.emplace_back(std::move(indexStatus.get_status()));
dataSet.rows.emplace_back(std::move(row));
}
return finish(ResultBuilder()
.value(Value(std::move(dataSet)))
.iter(Iterator::Kind::kDefault)
.finish());
});
}

} // namespace graph
} // namespace nebula
8 changes: 8 additions & 0 deletions src/executor/maintain/EdgeIndexExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class ShowEdgeIndexesExecutor final : public Executor {
folly::Future<Status> execute() override;
};

class ShowEdgeIndexStatusExecutor final : public Executor {
public:
ShowEdgeIndexStatusExecutor(const PlanNode *node, QueryContext *qctx)
: Executor("ShowEdgeIndexStatusExecutor", node, qctx) {}

folly::Future<Status> execute() override;
};

} // namespace graph
} // namespace nebula

Expand Down
29 changes: 29 additions & 0 deletions src/executor/maintain/TagIndexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,34 @@ folly::Future<Status> ShowTagIndexesExecutor::execute() {
});
}

folly::Future<Status> ShowTagIndexStatusExecutor::execute() {
SCOPED_TIMER(&execTime_);

auto spaceId = qctx()->rctx()->session()->space().id;
return qctx()->getMetaClient()->listTagIndexStatus(spaceId).via(runner()).then(
[this, spaceId](StatusOr<std::vector<meta::cpp2::IndexStatus>> resp) {
if (!resp.ok()) {
LOG(ERROR) << "SpaceId: " << spaceId << ", Show tag index status failed"
<< resp.status();
return resp.status();
}

auto indexStatuses = std::move(resp).value();

DataSet dataSet;
dataSet.colNames = {"Name", "Index Status"};
for (auto &indexStatus : indexStatuses) {
Row row;
row.values.emplace_back(std::move(indexStatus.get_name()));
row.values.emplace_back(std::move(indexStatus.get_status()));
dataSet.rows.emplace_back(std::move(row));
}
return finish(ResultBuilder()
.value(Value(std::move(dataSet)))
.iter(Iterator::Kind::kDefault)
.finish());
});
}

} // namespace graph
} // namespace nebula
8 changes: 8 additions & 0 deletions src/executor/maintain/TagIndexExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class ShowTagIndexesExecutor final : public Executor {
folly::Future<Status> execute() override;
};

class ShowTagIndexStatusExecutor final : public Executor {
public:
ShowTagIndexStatusExecutor(const PlanNode *node, QueryContext *qctx)
: Executor("ShowTagIndexStatusExecutor", node, qctx) {}

folly::Future<Status> execute() override;
};

} // namespace graph
} // namespace nebula

Expand Down
6 changes: 5 additions & 1 deletion src/parser/AdminSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,14 @@ std::string AdminJobSentence::toString() const {
LOG(FATAL) << "Unkown job operation " << static_cast<uint8_t>(op_);
}

meta::cpp2::AdminJobOp AdminJobSentence::getType() const {
meta::cpp2::AdminJobOp AdminJobSentence::getOp() const {
return op_;
}

meta::cpp2::AdminCmd AdminJobSentence::getCmd() const {
return cmd_;
}

const std::vector<std::string> &AdminJobSentence::getParas() const {
return paras_;
}
Expand Down
8 changes: 6 additions & 2 deletions src/parser/AdminSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,17 +558,21 @@ class ShowListenerSentence final : public Sentence {

class AdminJobSentence final : public Sentence {
public:
explicit AdminJobSentence(meta::cpp2::AdminJobOp op) : op_(op) {
explicit AdminJobSentence(meta::cpp2::AdminJobOp op,
meta::cpp2::AdminCmd cmd = meta::cpp2::AdminCmd::UNKNOWN)
: op_(op), cmd_(cmd) {
kind_ = Kind::kAdminJob;
}

void addPara(const std::string& para);
std::string toString() const override;
meta::cpp2::AdminJobOp getType() const;
meta::cpp2::AdminJobOp getOp() const;
meta::cpp2::AdminCmd getCmd() const;
const std::vector<std::string> &getParas() const;

private:
meta::cpp2::AdminJobOp op_;
meta::cpp2::AdminCmd cmd_;
std::vector<std::string> paras_;
};

Expand Down
8 changes: 8 additions & 0 deletions src/parser/MaintainSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,14 @@ std::string ShowEdgeIndexesSentence::toString() const {
return folly::stringPrintf("SHOW EDGE INDEXES");
}

std::string ShowTagIndexStatusSentence::toString() const {
return folly::stringPrintf("SHOW TAG INDEX STATUS");
}

std::string ShowEdgeIndexStatusSentence::toString() const {
return folly::stringPrintf("SHOW EDGE INDEX STATUS");
}

std::string ShowCreateTagIndexSentence::toString() const {
return folly::stringPrintf("SHOW CREATE TAG INDEX %s", indexName_.get()->c_str());
}
Expand Down
18 changes: 18 additions & 0 deletions src/parser/MaintainSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,24 @@ class ShowEdgeIndexesSentence : public Sentence {
std::string toString() const override;
};

class ShowTagIndexStatusSentence : public Sentence {
public:
ShowTagIndexStatusSentence() {
kind_ = Kind::kShowTagIndexStatus;
}

std::string toString() const override;
};

class ShowEdgeIndexStatusSentence : public Sentence {
public:
ShowEdgeIndexStatusSentence() {
kind_ = Kind::kShowEdgeIndexStatus;
}

std::string toString() const override;
};

class ShowCreateTagIndexSentence : public Sentence {
public:
explicit ShowCreateTagIndexSentence(std::string *indexName) {
Expand Down
2 changes: 2 additions & 0 deletions src/parser/Sentence.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class Sentence {
kShowEdges,
kShowTagIndexes,
kShowEdgeIndexes,
kShowTagIndexStatus,
kShowEdgeIndexStatus,
kShowUsers,
kShowRoles,
kShowCreateSpace,
Expand Down
Loading

0 comments on commit eac0742

Please sign in to comment.