Skip to content

Commit

Permalink
Add AlterEdgeProcessor, GetEdgeProcessor, RemoveEdgeProcessor and UTs (
Browse files Browse the repository at this point in the history
…vesoft-inc#346)

* add AlterEdgeProcessor, GetEdgeProcessor, RemoveEdgeProcessor

* address dangleptr's comment

* rebase master
modify SET to CHANGE

* fix UT
  • Loading branch information
laura-ding authored and dutor committed May 10, 2019
1 parent 34effb2 commit d6e853c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/executor/AlterTagExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ void AlterTagExecutor::execute() {
const auto& tagOpts = sentence_->tagOptList();
auto spaceId = ectx()->rctx()->session()->space();

std::vector<nebula::meta::cpp2::AlterTagItem> tagItems;
std::vector<nebula::meta::cpp2::AlterSchemaItem> tagItems;
for (auto& tagOpt : tagOpts) {
nebula::meta::cpp2::AlterTagItem tagItem;
nebula::meta::cpp2::AlterSchemaItem tagItem;
auto opType = getTagOpType(tagOpt->getOptType());
tagItem.set_op(std::move(opType));
const auto& specs = tagOpt->columnSpecs();
Expand Down Expand Up @@ -65,17 +65,17 @@ void AlterTagExecutor::execute() {
std::move(future).via(runner).thenValue(cb).thenError(error);
}

nebula::meta::cpp2::AlterTagOp
nebula::meta::cpp2::AlterSchemaOp
AlterTagExecutor::getTagOpType(const AlterTagOptItem::OptionType type) {
switch (type) {
case AlterTagOptItem::OptionType::ADD :
return nebula::meta::cpp2::AlterTagOp::ADD;
case AlterTagOptItem::OptionType::SET :
return nebula::meta::cpp2::AlterTagOp::SET;
return nebula::meta::cpp2::AlterSchemaOp::ADD;
case AlterTagOptItem::OptionType::CHANGE :
return nebula::meta::cpp2::AlterSchemaOp::CHANGE;
case AlterTagOptItem::OptionType::DROP :
return nebula::meta::cpp2::AlterTagOp::DROP;
return nebula::meta::cpp2::AlterSchemaOp::DROP;
default:
return nebula::meta::cpp2::AlterTagOp::UNKNOWN;
return nebula::meta::cpp2::AlterSchemaOp::UNKNOWN;
}
}
} // namespace graph
Expand Down
2 changes: 1 addition & 1 deletion src/executor/AlterTagExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AlterTagExecutor final : public Executor {

private:
AlterTagSentence *sentence_{nullptr};
nebula::meta::cpp2::AlterTagOp
nebula::meta::cpp2::AlterSchemaOp
getTagOpType(const AlterTagOptItem::OptionType type);
};

Expand Down
5 changes: 1 addition & 4 deletions src/executor/test/SchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ TEST_F(SchemaTest, metaCommunication) {
cpp2::ExecutionResponse resp;
std::string query = "ALTER TAG account "
"ADD (col1 int TTL = 200, col2 string), "
"SET (balance string), "
"CHANGE (balance string), "
"DROP (id)";
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
Expand Down Expand Up @@ -208,13 +208,10 @@ TEST_F(SchemaTest, metaCommunication) {
};
ASSERT_TRUE(verifyResult(resp, expected));
}
/* test the same tag in diff space, but now meta server not supported,
* will add a issue(#292) to resolve it */
{
cpp2::ExecutionResponse resp;
std::string query = "CREATE TAG person(name string, interest string)";
auto code = client->execute(query, resp);
sleep(FLAGS_load_data_interval_second + 1);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
{
Expand Down
2 changes: 1 addition & 1 deletion src/parser/MaintainSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AlterTagOptItem final {
public:
enum OptionType : uint8_t {
ADD = 0x01,
SET = 0x02,
CHANGE = 0x02,
DROP = 0x03
};

Expand Down
4 changes: 2 additions & 2 deletions src/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ alter_tag_opt_item
: KW_ADD L_PAREN column_spec_list R_PAREN {
$$ = new AlterTagOptItem(AlterTagOptItem::ADD, $3);
}
| KW_SET L_PAREN column_spec_list R_PAREN {
$$ = new AlterTagOptItem(AlterTagOptItem::SET, $3);
| KW_CHANGE L_PAREN column_spec_list R_PAREN {
$$ = new AlterTagOptItem(AlterTagOptItem::CHANGE, $3);
}
| KW_DROP L_PAREN column_spec_list R_PAREN {
$$ = new AlterTagOptItem(AlterTagOptItem::DROP, $3);
Expand Down
2 changes: 1 addition & 1 deletion src/parser/test/ParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TEST(Parser, AlterTag) {
{
GQLParser parser;
std::string query = "ALTER TAG person ADD (col1 int TTL = 200, col2 string), "
"SET (col3 int TTL = 200, col4 string), "
"CHANGE (col3 int TTL = 200, col4 string), "
"DROP (col5, col6)";
auto result = parser.parse(query);
ASSERT_TRUE(result.ok()) << result.status();
Expand Down

0 comments on commit d6e853c

Please sign in to comment.