Skip to content
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

[Reopen] Unify remove to drop in schema #391

Merged
merged 12 commits into from
May 22, 2019
4 changes: 2 additions & 2 deletions src/graph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ add_library(
CreateTagExecutor.cpp
AlterEdgeExecutor.cpp
AlterTagExecutor.cpp
RemoveTagExecutor.cpp
RemoveEdgeExecutor.cpp
DropTagExecutor.cpp
DropEdgeExecutor.cpp
DescribeTagExecutor.cpp
DescribeEdgeExecutor.cpp
InsertVertexExecutor.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#include "graph/RemoveTagExecutor.h"
#include "graph/DropEdgeExecutor.h"

namespace nebula {
namespace graph {

RemoveTagExecutor::RemoveTagExecutor(Sentence *sentence,
ExecutionContext *ectx) : Executor(ectx) {
sentence_ = static_cast<RemoveTagSentence*>(sentence);
DropEdgeExecutor::DropEdgeExecutor(Sentence *sentence,
ExecutionContext *ectx) : Executor(ectx) {
sentence_ = static_cast<DropEdgeSentence*>(sentence);
}

Status RemoveTagExecutor::prepare() {
Status DropEdgeExecutor::prepare() {
return checkIfGraphSpaceChosen();
}

void RemoveTagExecutor::execute() {
void DropEdgeExecutor::execute() {
auto *mc = ectx()->getMetaClient();
auto *name = sentence_->name();
auto spaceId = ectx()->rctx()->session()->space();
auto future = mc->removeTagSchema(spaceId, *name);
auto future = mc->dropEdgeSchema(spaceId, *name);

auto *runner = ectx()->rctx()->runner();
auto cb = [this] (auto &&resp) {
Expand All @@ -47,3 +47,4 @@ void RemoveTagExecutor::execute() {

} // namespace graph
} // namespace nebula

15 changes: 7 additions & 8 deletions src/graph/RemoveTagExecutor.h → src/graph/DropEdgeExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,32 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#ifndef GRAPH_REMOVETAGEXECUTOR_H
#define GRAPH_REMOVETAGEXECUTOR_H
#ifndef GRAPH_DROPEDGEEXECUTOR_H
#define GRAPH_DROPEDGEEXECUTOR_H

#include "base/Base.h"
#include "graph/Executor.h"

namespace nebula {
namespace graph {

class RemoveTagExecutor final : public Executor {
class DropEdgeExecutor final : public Executor {
public:
RemoveTagExecutor(Sentence *sentence, ExecutionContext *context);
DropEdgeExecutor(Sentence *sentence, ExecutionContext *context);

const char* name() const override {
return "RemoveTagExecutor";
return "DropEdgeExecutor";
}

Status MUST_USE_RESULT prepare() override;

void execute() override;

private:
RemoveTagSentence *sentence_{nullptr};
DropEdgeSentence *sentence_{nullptr};
};

} // namespace graph
} // namespace nebula

#endif // GRAPH_REMOVETAGEXECUTOR_H

#endif // GRAPH_DROPEDGEEXECUTOR_H
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#include "graph/RemoveEdgeExecutor.h"
#include "graph/DropTagExecutor.h"

namespace nebula {
namespace graph {

RemoveEdgeExecutor::RemoveEdgeExecutor(Sentence *sentence,
ExecutionContext *ectx) : Executor(ectx) {
sentence_ = static_cast<RemoveEdgeSentence*>(sentence);
DropTagExecutor::DropTagExecutor(Sentence *sentence,
ExecutionContext *ectx) : Executor(ectx) {
sentence_ = static_cast<DropTagSentence*>(sentence);
}

Status RemoveEdgeExecutor::prepare() {
Status DropTagExecutor::prepare() {
return checkIfGraphSpaceChosen();
}

void RemoveEdgeExecutor::execute() {
void DropTagExecutor::execute() {
auto *mc = ectx()->getMetaClient();
auto *name = sentence_->name();
auto spaceId = ectx()->rctx()->session()->space();
auto future = mc->removeEdgeSchema(spaceId, *name);
auto future = mc->dropTagSchema(spaceId, *name);

auto *runner = ectx()->rctx()->runner();
auto cb = [this] (auto &&resp) {
Expand All @@ -47,3 +47,4 @@ void RemoveEdgeExecutor::execute() {

} // namespace graph
} // namespace nebula

15 changes: 7 additions & 8 deletions src/graph/RemoveEdgeExecutor.h → src/graph/DropTagExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,32 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#ifndef GRAPH_REMOVEEDGEEXECUTOR_H
#define GRAPH_REMOVEEDGEEXECUTOR_H
#ifndef GRAPH_DROPTAGEXECUTOR_H
#define GRAPH_DROPTAGEXECUTOR_H

#include "base/Base.h"
#include "graph/Executor.h"

namespace nebula {
namespace graph {

class RemoveEdgeExecutor final : public Executor {
class DropTagExecutor final : public Executor {
public:
RemoveEdgeExecutor(Sentence *sentence, ExecutionContext *context);
DropTagExecutor(Sentence *sentence, ExecutionContext *context);

const char* name() const override {
return "RemoveEdgeExecutor";
return "DropTagExecutor";
}

Status MUST_USE_RESULT prepare() override;

void execute() override;

private:
RemoveEdgeSentence *sentence_{nullptr};
DropTagSentence *sentence_{nullptr};
};

} // namespace graph
} // namespace nebula

#endif // GRAPH_REMOVEEDGEEXECUTOR_H

#endif // GRAPH_DROPTAGEXECUTOR_H
12 changes: 6 additions & 6 deletions src/graph/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "graph/CreateEdgeExecutor.h"
#include "graph/AlterTagExecutor.h"
#include "graph/AlterEdgeExecutor.h"
#include "graph/RemoveTagExecutor.h"
#include "graph/RemoveEdgeExecutor.h"
#include "graph/DropTagExecutor.h"
#include "graph/DropEdgeExecutor.h"
#include "graph/DescribeTagExecutor.h"
#include "graph/DescribeEdgeExecutor.h"
#include "graph/InsertVertexExecutor.h"
Expand Down Expand Up @@ -65,11 +65,11 @@ std::unique_ptr<Executor> Executor::makeExecutor(Sentence *sentence) {
case Sentence::Kind::kDescribeEdge:
executor = std::make_unique<DescribeEdgeExecutor>(sentence, ectx());
break;
case Sentence::Kind::kRemoveTag:
executor = std::make_unique<RemoveTagExecutor>(sentence, ectx());
case Sentence::Kind::kDropTag:
executor = std::make_unique<DropTagExecutor>(sentence, ectx());
break;
case Sentence::Kind::kRemoveEdge:
executor = std::make_unique<RemoveEdgeExecutor>(sentence, ectx());
case Sentence::Kind::kDropEdge:
executor = std::make_unique<DropEdgeExecutor>(sentence, ectx());
break;
case Sentence::Kind::kInsertVertex:
executor = std::make_unique<InsertVertexExecutor>(sentence, ectx());
Expand Down
1 change: 1 addition & 0 deletions src/graph/RemoveHostsExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ void RemoveHostsExecutor::execute() {

} // namespace graph
} // namespace nebula

1 change: 1 addition & 0 deletions src/graph/RemoveHostsExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ class RemoveHostsExecutor final : public Executor {
} // namespace nebula

#endif // GRAPH_REMOVEHOSTSEXECUTOR_H_

2 changes: 1 addition & 1 deletion src/graph/test/SchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ TEST_F(SchemaTest, metaCommunication) {
}
{
cpp2::ExecutionResponse resp;
std::string query = "REMOVE TAG person ";
std::string query = "DROP TAG person ";
auto code = client->execute(query, resp);
sleep(FLAGS_load_data_interval_secs + 1);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
Expand Down
8 changes: 4 additions & 4 deletions src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct AlterTagReq {
3: list<AlterSchemaItem> tag_items,
}

struct RemoveTagReq {
struct DropTagReq {
1: common.GraphSpaceID space_id,
2: string tag_name,
}
Expand Down Expand Up @@ -183,7 +183,7 @@ struct GetEdgeResp {
3: common.Schema schema,
}

struct RemoveEdgeReq {
struct DropEdgeReq {
1: common.GraphSpaceID space_id,
2: string edge_name,
}
Expand Down Expand Up @@ -299,13 +299,13 @@ service MetaService {

ExecResp createTag(1: CreateTagReq req);
ExecResp alterTag(1: AlterTagReq req);
ExecResp removeTag(1: RemoveTagReq req);
ExecResp dropTag(1: DropTagReq req);
GetTagResp getTag(1: GetTagReq req);
ListTagsResp listTags(1: ListTagsReq req);

ExecResp createEdge(1: CreateEdgeReq req);
ExecResp alterEdge(1: AlterEdgeReq req);
ExecResp removeEdge(1: RemoveEdgeReq req);
ExecResp dropEdge(1: DropEdgeReq req);
GetEdgeResp getEdge(1: GetEdgeReq req);
ListEdgesResp listEdges(1: ListEdgesReq req);

Expand Down
4 changes: 2 additions & 2 deletions src/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ add_library(
processors/GetEdgeProcessor.cpp
processors/ListTagsProcessor.cpp
processors/ListEdgesProcessor.cpp
processors/RemoveTagProcessor.cpp
processors/RemoveEdgeProcessor.cpp
processors/DropTagProcessor.cpp
processors/DropEdgeProcessor.cpp
processors/GetProcessor.cpp
processors/MultiGetProcessor.cpp
processors/MultiPutProcessor.cpp
Expand Down
14 changes: 7 additions & 7 deletions src/meta/MetaServiceHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
#include "meta/processors/AddHostsProcessor.h"
#include "meta/processors/ListHostsProcessor.h"
#include "meta/processors/RemoveHostsProcessor.h"
#include "meta/processors/GetPartsAllocProcessor.h"
#include "meta/processors/CreateTagProcessor.h"
#include "meta/processors/AlterTagProcessor.h"
#include "meta/processors/DropTagProcessor.h"
#include "meta/processors/GetTagProcessor.h"
#include "meta/processors/ListTagsProcessor.h"
#include "meta/processors/RemoveTagProcessor.h"
#include "meta/processors/CreateEdgeProcessor.h"
#include "meta/processors/AlterEdgeProcessor.h"
#include "meta/processors/DropEdgeProcessor.h"
#include "meta/processors/GetEdgeProcessor.h"
#include "meta/processors/ListEdgesProcessor.h"
#include "meta/processors/RemoveEdgeProcessor.h"
#include "meta/processors/MultiPutProcessor.h"
#include "meta/processors/GetProcessor.h"
#include "meta/processors/MultiGetProcessor.h"
#include "meta/processors/ScanProcessor.h"
#include "meta/processors/RemoveProcessor.h"
#include "meta/processors/RemoveRangeProcessor.h"
#include "meta/processors/GetPartsAllocProcessor.h"
#include "meta/processors/HBProcessor.h"

#define RETURN_FUTURE(processor) \
Expand Down Expand Up @@ -130,8 +130,8 @@ MetaServiceHandler::future_alterTag(const cpp2::AlterTagReq& req) {
}

folly::Future<cpp2::ExecResp>
MetaServiceHandler::future_removeTag(const cpp2::RemoveTagReq& req) {
auto* processor = RemoveTagProcessor::instance(kvstore_);
MetaServiceHandler::future_dropTag(const cpp2::DropTagReq& req) {
auto* processor = DropTagProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

Expand Down Expand Up @@ -160,8 +160,8 @@ MetaServiceHandler::future_alterEdge(const cpp2::AlterEdgeReq& req) {
}

folly::Future<cpp2::ExecResp>
MetaServiceHandler::future_removeEdge(const cpp2::RemoveEdgeReq& req) {
auto* processor = RemoveEdgeProcessor::instance(kvstore_);
MetaServiceHandler::future_dropEdge(const cpp2::DropEdgeReq& req) {
auto* processor = DropEdgeProcessor::instance(kvstore_);
RETURN_FUTURE(processor);
}

Expand Down
4 changes: 2 additions & 2 deletions src/meta/MetaServiceHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MetaServiceHandler final : public cpp2::MetaServiceSvIf {
future_alterTag(const cpp2::AlterTagReq& req) override;

folly::Future<cpp2::ExecResp>
future_removeTag(const cpp2::RemoveTagReq& req) override;
future_dropTag(const cpp2::DropTagReq& req) override;

folly::Future<cpp2::GetTagResp>
future_getTag(const cpp2::GetTagReq &req) override;
Expand All @@ -90,7 +90,7 @@ class MetaServiceHandler final : public cpp2::MetaServiceSvIf {
future_alterEdge(const cpp2::AlterEdgeReq& req) override;

folly::Future<cpp2::ExecResp>
future_removeEdge(const cpp2::RemoveEdgeReq& req) override;
future_dropEdge(const cpp2::DropEdgeReq& req) override;

folly::Future<cpp2::GetEdgeResp>
future_getEdge(const cpp2::GetEdgeReq& req) override;
Expand Down
12 changes: 6 additions & 6 deletions src/meta/client/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,12 @@ MetaClient::listTagSchemas(GraphSpaceID spaceId) {
}

folly::Future<StatusOr<bool>>
MetaClient::removeTagSchema(int32_t spaceId, std::string tagName) {
cpp2::RemoveTagReq req;
MetaClient::dropTagSchema(int32_t spaceId, std::string tagName) {
cpp2::DropTagReq req;
req.set_space_id(spaceId);
req.set_tag_name(std::move(tagName));
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_removeTag(request);
return client->future_dropTag(request);
}, [] (cpp2::ExecResp&& resp) -> bool {
return resp.code == cpp2::ErrorCode::SUCCEEDED;
}, true);
Expand Down Expand Up @@ -778,12 +778,12 @@ MetaClient::getEdgeSchema(GraphSpaceID spaceId, int32_t edgeType, SchemaVer vers
}

folly::Future<StatusOr<bool>>
MetaClient::removeEdgeSchema(GraphSpaceID spaceId, std::string name) {
cpp2::RemoveEdgeReq req;
MetaClient::dropEdgeSchema(GraphSpaceID spaceId, std::string name) {
cpp2::DropEdgeReq req;
req.set_space_id(std::move(spaceId));
req.set_edge_name(std::move(name));
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_removeEdge(request);
return client->future_dropEdge(request);
}, [] (cpp2::ExecResp&& resp) -> bool {
return resp.code == cpp2::ErrorCode::SUCCEEDED;
}, true);
Expand Down
4 changes: 2 additions & 2 deletions src/meta/client/MetaClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class MetaClient {
listTagSchemas(GraphSpaceID spaceId);

folly::Future<StatusOr<bool>>
removeTagSchema(int32_t spaceId, std::string name);
dropTagSchema(int32_t spaceId, std::string name);

folly::Future<StatusOr<nebula::cpp2::Schema>>
getTagSchema(int32_t spaceId, int32_t tagId, int64_t version);
Expand All @@ -129,7 +129,7 @@ class MetaClient {
getEdgeSchema(GraphSpaceID spaceId, int32_t edgeType, SchemaVer version);

folly::Future<StatusOr<bool>>
removeEdgeSchema(GraphSpaceID spaceId, std::string name);
dropEdgeSchema(GraphSpaceID spaceId, std::string name);

// Operations for custom kv
folly::Future<StatusOr<bool>>
Expand Down
Loading