Skip to content
Snippets Groups Projects
Unverified Commit f5ad03a8 authored by Shylock Hg's avatar Shylock Hg Committed by GitHub
Browse files

Add explain for some plan nodes. (#226)


* Add explain for some plan nodes.

* Remove the unused cmake.

* Mask the password.

Co-authored-by: default avatarYee <2520865+yixinglu@users.noreply.github.com>
Co-authored-by: default avatardutor <440396+dutor@users.noreply.github.com>
parent 7f1486d7
No related branches found
No related tags found
No related merge requests found
......@@ -72,5 +72,94 @@ std::unique_ptr<cpp2::PlanNodeDescription> GetConfig::explain() const {
addDescription("name", name_, desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> CreateNode::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("ifNotExist", util::toJson(ifNotExist_), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> DropNode::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("ifExist", util::toJson(ifExist_), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> CreateUser::explain() const {
auto desc = CreateNode::explain();
addDescription("username", *username_, desc.get());
addDescription("password", "******", desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> DropUser::explain() const {
auto desc = DropNode::explain();
addDescription("username", *username_, desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> UpdateUser::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("username", *username_, desc.get());
addDescription("password", "******", desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> GrantRole::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("username", *username_, desc.get());
addDescription("spaceName", *spaceName_, desc.get());
addDescription("role", meta::cpp2::_RoleType_VALUES_TO_NAMES.at(role_), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> RevokeRole::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("username", *username_, desc.get());
addDescription("spaceName", *spaceName_, desc.get());
addDescription("role", meta::cpp2::_RoleType_VALUES_TO_NAMES.at(role_), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> ChangePassword::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("username", *username_, desc.get());
addDescription("password", "******", desc.get());
addDescription("newPassword", "******", desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> ListUserRoles::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("username", *username_, desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> ListRoles::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("space", util::toJson(space_), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> SubmitJob::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("operation", meta::cpp2::_AdminJobOp_VALUES_TO_NAMES.at(op_), desc.get());
addDescription("command", meta::cpp2::_AdminCmd_VALUES_TO_NAMES.at(cmd_), desc.get());
addDescription("parameters", folly::toJson(util::toJson(params_)), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> Balance::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("deleteHosts", folly::toJson(util::toJson(deleteHosts_)), desc.get());
return desc;
}
std::unique_ptr<cpp2::PlanNodeDescription> ShowBalance::explain() const {
auto desc = SingleDependencyNode::explain();
addDescription("balanceId", util::toJson(id_), desc.get());
return desc;
}
} // namespace graph
} // namespace nebula
......@@ -27,6 +27,8 @@ protected:
CreateNode(ExecutionPlan* plan, Kind kind, PlanNode* input, bool ifNotExist = false)
: SingleDependencyNode(plan, kind, input), ifNotExist_(ifNotExist) {}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
public:
bool ifNotExist() const {
return ifNotExist_;
......@@ -41,6 +43,8 @@ protected:
DropNode(ExecutionPlan* plan, Kind kind, PlanNode* input, bool ifExist = false)
: SingleDependencyNode(plan, kind, input), ifExist_(ifExist) {}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
public:
bool ifExist() const {
return ifExist_;
......@@ -367,10 +371,7 @@ public:
ifNotExists);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -407,10 +408,7 @@ public:
ifNotExists);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -437,10 +435,7 @@ public:
password);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -478,10 +473,7 @@ public:
role);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -526,10 +518,7 @@ public:
role);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -574,10 +563,7 @@ public:
newPassword);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -619,10 +605,7 @@ public:
username);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::string* username() const {
return username_;
......@@ -643,11 +626,6 @@ public:
return new ListUsers(plan, dep);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
private:
explicit ListUsers(ExecutionPlan* plan, PlanNode* dep)
: SingleDependencyNode(plan, Kind::kListUsers, dep) {}
......@@ -659,10 +637,7 @@ public:
return new ListRoles(plan, dep, space);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
GraphSpaceID space() const {
return space_;
......@@ -718,11 +693,7 @@ public:
return new SubmitJob(plan, dep, op, params);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
// TODO(shylock)
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
public:
meta::cpp2::AdminJobOp jobOp() const {
......@@ -759,11 +730,6 @@ public:
return new BalanceLeaders(plan, dep);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
private:
explicit BalanceLeaders(ExecutionPlan* plan, PlanNode* dep)
: SingleDependencyNode(plan, Kind::kBalanceLeaders, dep) {}
......@@ -775,10 +741,7 @@ public:
return new Balance(plan, dep, std::move(deleteHosts));
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
const std::vector<HostAddr> &deleteHosts() const {
return deleteHosts_;
......@@ -797,11 +760,6 @@ public:
return new StopBalance(plan, dep);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
private:
explicit StopBalance(ExecutionPlan* plan, PlanNode* dep)
: SingleDependencyNode(plan, Kind::kStopBalance, dep) {}
......@@ -813,10 +771,7 @@ public:
return new ShowBalance(plan, dep, id);
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override {
LOG(FATAL) << "Unimplemented";
return nullptr;
}
std::unique_ptr<cpp2::PlanNodeDescription> explain() const override;
int64_t id() const {
return id_;
......
......@@ -53,4 +53,4 @@ nebula_add_test(
proxygenlib
${THRIFT_LIBRARIES}
wangle
)
)
......@@ -33,6 +33,10 @@ std::string toJson(bool b) {
return b ? "true" : "false";
}
std::string toJson(const HostAddr &addr) {
return addr.toString();
}
std::string toJson(const List &list) {
return list.toString();
}
......
......@@ -19,6 +19,7 @@ class EdgeKeyRef;
class Expression;
struct List;
struct Value;
struct HostAddr;
namespace meta {
struct SpaceDesc;
......@@ -55,6 +56,7 @@ std::string toJson(int32_t i);
std::string toJson(int64_t i);
std::string toJson(bool b);
std::string toJson(const HostAddr &addr);
std::string toJson(const List &list);
std::string toJson(const Value &value);
std::string toJson(const EdgeKeyRef *ref);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment