Skip to content

Commit

Permalink
Move SchemaID from meta.thrift to common.thrift (#2560)
Browse files Browse the repository at this point in the history
Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com>
Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 27, 2021
1 parent d886310 commit f490d4d
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3329,7 +3329,7 @@ StatusOr<std::pair<std::string, cpp2::FTIndex>> MetaClient::getFTIndexBySpaceSch
}
folly::RWSpinLock::ReadHolder holder(localCacheLock_);
for (auto it = fulltextIndexMap_.begin(); it != fulltextIndexMap_.end(); ++it) {
auto id = it->second.get_depend_schema().getType() == cpp2::SchemaID::Type::edge_type
auto id = it->second.get_depend_schema().getType() == nebula::cpp2::SchemaID::Type::edge_type
? it->second.get_depend_schema().get_edge_type()
: it->second.get_depend_schema().get_tag_id();
if (it->second.get_space_id() == spaceId && id == schemaId) {
Expand Down
2 changes: 1 addition & 1 deletion src/graph/executor/maintain/FTIndexExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ folly::Future<Status> ShowFTIndexesExecutor::execute() {
continue;
}
auto shmId = index.second.get_depend_schema();
auto isEdge = shmId.getType() == meta::cpp2::SchemaID::Type::edge_type;
auto isEdge = shmId.getType() == nebula::cpp2::SchemaID::Type::edge_type;
auto shmNameRet =
isEdge ? this->qctx_->schemaMng()->toEdgeName(spaceId, shmId.get_edge_type())
: this->qctx_->schemaMng()->toTagName(spaceId, shmId.get_tag_id());
Expand Down
2 changes: 1 addition & 1 deletion src/graph/validator/MaintainValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Status CreateFTIndexValidator::validateImpl() {
? qctx_->schemaMng()->toEdgeType(space.id, *sentence->schemaName())
: qctx_->schemaMng()->toTagID(space.id, *sentence->schemaName());
NG_RETURN_IF_ERROR(status);
meta::cpp2::SchemaID id;
nebula::cpp2::SchemaID id;
if (sentence->isEdge()) {
id.set_edge_type(status.value());
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/graph/validator/test/MockIndexManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ void MockIndexManager::init() {
meta::cpp2::IndexItem person_no_props_index;
person_no_props_index.set_index_id(233);
person_no_props_index.set_index_name("person_no_props_index");
meta::cpp2::SchemaID personSchemaId;
nebula::cpp2::SchemaID personSchemaId;
personSchemaId.set_tag_id(2);
person_no_props_index.set_schema_id(std::move(personSchemaId));
person_no_props_index.set_schema_name("person");

meta::cpp2::IndexItem book_name_index;
book_name_index.set_index_id(234);
book_name_index.set_index_name("book_name_index");
meta::cpp2::SchemaID bookSchemaId;
nebula::cpp2::SchemaID bookSchemaId;
bookSchemaId.set_tag_id(5);
book_name_index.set_schema_id(std::move(bookSchemaId));
book_name_index.set_schema_name("book");
Expand All @@ -47,7 +47,7 @@ void MockIndexManager::init() {
meta::cpp2::IndexItem like_index;
like_index.set_index_id(235);
like_index.set_index_name("like_index");
meta::cpp2::SchemaID likeSchemaId;
nebula::cpp2::SchemaID likeSchemaId;
likeSchemaId.set_edge_type(3);
like_index.set_schema_id(std::move(likeSchemaId));
like_index.set_schema_name("like");
Expand Down
5 changes: 5 additions & 0 deletions src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ typedef i64 (cpp.type = "nebula::SessionID") SessionID

typedef i64 (cpp.type = "nebula::ExecutionPlanID") ExecutionPlanID

union SchemaID {
1: TagID tag_id,
2: EdgeType edge_type,
}

// !! Struct Date has a shadow data type defined in the Date.h
// So any change here needs to be reflected to the shadow type there
struct Date {
Expand Down
9 changes: 2 additions & 7 deletions src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,10 @@ struct EdgeItem {
4: Schema schema,
}

union SchemaID {
1: common.TagID tag_id,
2: common.EdgeType edge_type,
}

struct IndexItem {
1: common.IndexID index_id,
2: binary index_name,
3: SchemaID schema_id
3: common.SchemaID schema_id
4: binary schema_name,
5: list<ColumnDef> fields,
6: optional binary comment,
Expand Down Expand Up @@ -1042,7 +1037,7 @@ struct ListFTClientsResp {

struct FTIndex {
1: common.GraphSpaceID space_id,
2: SchemaID depend_schema,
2: common.SchemaID depend_schema,
3: list<binary> fields,
}

Expand Down
6 changes: 3 additions & 3 deletions src/meta/processors/BaseProcessor-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ ErrorOr<nebula::cpp2::ErrorCode, std::vector<cpp2::IndexItem>> BaseProcessor<RES

while (indexIter->valid()) {
auto item = MetaServiceUtils::parseIndex(indexIter->val());
if (item.get_schema_id().getType() == cpp2::SchemaID::Type::tag_id &&
if (item.get_schema_id().getType() == nebula::cpp2::SchemaID::Type::tag_id &&
item.get_schema_id().get_tag_id() == tagOrEdge) {
items.emplace_back(std::move(item));
} else if (item.get_schema_id().getType() == cpp2::SchemaID::Type::edge_type &&
} else if (item.get_schema_id().getType() == nebula::cpp2::SchemaID::Type::edge_type &&
item.get_schema_id().get_edge_type() == tagOrEdge) {
items.emplace_back(std::move(item));
}
Expand All @@ -491,7 +491,7 @@ ErrorOr<nebula::cpp2::ErrorCode, cpp2::FTIndex> BaseProcessor<RESP>::getFTIndex(

while (indexIter->valid()) {
auto index = MetaServiceUtils::parsefulltextIndex(indexIter->val());
auto id = index.get_depend_schema().getType() == cpp2::SchemaID::Type::edge_type
auto id = index.get_depend_schema().getType() == nebula::cpp2::SchemaID::Type::edge_type
? index.get_depend_schema().get_edge_type()
: index.get_depend_schema().get_tag_id();
if (spaceId == index.get_space_id() && tagOrEdge == id) {
Expand Down
4 changes: 2 additions & 2 deletions src/meta/processors/index/CreateEdgeIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void CreateEdgeIndexProcessor::process(const cpp2::CreateEdgeIndexReq& req) {
while (checkIter->valid()) {
auto val = checkIter->val();
auto item = MetaServiceUtils::parseIndex(val);
if (item.get_schema_id().getType() != cpp2::SchemaID::Type::edge_type ||
if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::edge_type ||
fields.size() > item.get_fields().size() ||
edgeType != item.get_schema_id().get_edge_type()) {
checkIter->next();
Expand Down Expand Up @@ -173,7 +173,7 @@ void CreateEdgeIndexProcessor::process(const cpp2::CreateEdgeIndexReq& req) {
cpp2::IndexItem item;
item.set_index_id(edgeIndex);
item.set_index_name(indexName);
cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
schemaID.set_edge_type(edgeType);
item.set_schema_id(schemaID);
item.set_schema_name(edgeName);
Expand Down
4 changes: 2 additions & 2 deletions src/meta/processors/index/CreateTagIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void CreateTagIndexProcessor::process(const cpp2::CreateTagIndexReq& req) {
while (checkIter->valid()) {
auto val = checkIter->val();
auto item = MetaServiceUtils::parseIndex(val);
if (item.get_schema_id().getType() != cpp2::SchemaID::Type::tag_id ||
if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::tag_id ||
fields.size() > item.get_fields().size() || tagID != item.get_schema_id().get_tag_id()) {
checkIter->next();
continue;
Expand Down Expand Up @@ -171,7 +171,7 @@ void CreateTagIndexProcessor::process(const cpp2::CreateTagIndexReq& req) {
cpp2::IndexItem item;
item.set_index_id(tagIndex);
item.set_index_name(indexName);
cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
schemaID.set_tag_id(tagID);
item.set_schema_id(schemaID);
item.set_schema_name(tagName);
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/index/FTIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void CreateFTIndexProcessor::process(const cpp2::CreateFTIndexReq& req) {
const auto& index = req.get_index();
const std::string& name = req.get_fulltext_index_name();
CHECK_SPACE_ID_AND_RETURN(index.get_space_id());
auto isEdge = index.get_depend_schema().getType() == cpp2::SchemaID::Type::edge_type;
auto isEdge = index.get_depend_schema().getType() == nebula::cpp2::SchemaID::Type::edge_type;
folly::SharedMutex::ReadHolder rHolder(isEdge ? LockUtils::edgeLock() : LockUtils::tagLock());
auto schemaPrefix = isEdge ? MetaServiceUtils::schemaEdgePrefix(
index.get_space_id(), index.get_depend_schema().get_edge_type())
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/index/GetEdgeIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void GetEdgeIndexProcessor::process(const cpp2::GetEdgeIndexReq& req) {
}

auto item = MetaServiceUtils::parseIndex(nebula::value(indexItemRet));
if (item.get_schema_id().getType() != cpp2::SchemaID::Type::edge_type) {
if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::edge_type) {
LOG(ERROR) << "Get Edge Index Failed: Index Name " << indexName << " is not EdgeIndex";
resp_.set_code(nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND);
onFinished();
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/index/GetTagIndexProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void GetTagIndexProcessor::process(const cpp2::GetTagIndexReq& req) {
}

auto item = MetaServiceUtils::parseIndex(nebula::value(indexItemRet));
if (item.get_schema_id().getType() != cpp2::SchemaID::Type::tag_id) {
if (item.get_schema_id().getType() != nebula::cpp2::SchemaID::Type::tag_id) {
LOG(ERROR) << "Get Tag Index Failed: Index Name " << indexName << " is not TagIndex";
resp_.set_code(nebula::cpp2::ErrorCode::E_INDEX_NOT_FOUND);
onFinished();
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/index/ListEdgeIndexesProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ListEdgeIndexesProcessor::process(const cpp2::ListEdgeIndexesReq& req) {
while (iter->valid()) {
auto val = iter->val();
auto item = MetaServiceUtils::parseIndex(val);
if (item.get_schema_id().getType() == cpp2::SchemaID::Type::edge_type) {
if (item.get_schema_id().getType() == nebula::cpp2::SchemaID::Type::edge_type) {
items.emplace_back(std::move(item));
}
iter->next();
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/index/ListTagIndexesProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ListTagIndexesProcessor::process(const cpp2::ListTagIndexesReq& req) {
while (iter->valid()) {
auto val = iter->val();
auto item = MetaServiceUtils::parseIndex(val);
if (item.get_schema_id().getType() == cpp2::SchemaID::Type::tag_id) {
if (item.get_schema_id().getType() == nebula::cpp2::SchemaID::Type::tag_id) {
items.emplace_back(std::move(item));
}
iter->next();
Expand Down
2 changes: 1 addition & 1 deletion src/meta/test/CreateBackupProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ TEST(ProcessorTest, CreateBackupTest) {
cpp2::IndexItem item;
item.set_index_id(tagIndex);
item.set_index_name(indexName);
cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
TagID tagID = 3;
std::string tagName = "test_space_tag1";
schemaID.set_tag_id(tagID);
Expand Down
26 changes: 13 additions & 13 deletions src/meta/test/IndexProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(5);
} else {
Expand All @@ -1627,7 +1627,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(5);
} else {
Expand All @@ -1649,7 +1649,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(5);
} else {
Expand All @@ -1671,7 +1671,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(55);
} else {
Expand All @@ -1695,7 +1695,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(5);
} else {
Expand All @@ -1720,7 +1720,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
schemaId.set_tag_id(5);
index.set_space_id(1);
index.set_depend_schema(std::move(schemaId));
Expand All @@ -1738,7 +1738,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
schemaId.set_tag_id(5);
index.set_space_id(1);
index.set_depend_schema(std::move(schemaId));
Expand All @@ -1756,7 +1756,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
schemaId.set_tag_id(5);
index.set_space_id(1);
index.set_depend_schema(std::move(schemaId));
Expand All @@ -1774,7 +1774,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
schemaId.set_tag_id(5);
index.set_space_id(1);
index.set_depend_schema(std::move(schemaId));
Expand All @@ -1792,7 +1792,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
schemaId.set_edge_type(6);
index.set_space_id(1);
index.set_depend_schema(std::move(schemaId));
Expand All @@ -1819,7 +1819,7 @@ TEST(IndexProcessorTest, CreateFTIndexTest) {
std::vector<std::string> fields = {"col_string", "col_fixed_string_1"};
ASSERT_EQ(fields, index->second.get_fields());
ASSERT_EQ(1, index->second.get_space_id());
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
schemaId.set_tag_id(5);
ASSERT_EQ(schemaId, index->second.get_depend_schema());
}
Expand Down Expand Up @@ -1865,7 +1865,7 @@ TEST(IndexProcessorTest, DropWithFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(5);
} else {
Expand Down Expand Up @@ -1916,7 +1916,7 @@ TEST(IndexProcessorTest, AlterWithFTIndexTest) {
{
cpp2::CreateFTIndexReq req;
cpp2::FTIndex index;
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (id == 5) {
schemaId.set_tag_id(5);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/meta/test/TestUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ class TestUtils {
cpp2::IndexItem item;
item.set_index_id(indexID);
item.set_index_name(indexName);
cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
schemaID.set_tag_id(tagID);
item.set_schema_id(std::move(schemaID));
item.set_schema_name(std::move(tagName));
Expand Down Expand Up @@ -328,7 +328,7 @@ class TestUtils {
cpp2::IndexItem item;
item.set_index_id(indexID);
item.set_index_name(indexName);
cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
schemaID.set_edge_type(edgeType);
item.set_schema_id(std::move(schemaID));
item.set_schema_name(std::move(edgeName));
Expand Down
2 changes: 1 addition & 1 deletion src/meta/upgrade/MetaDataUpgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Status MetaDataUpgrade::rewriteIndexes(const folly::StringPiece &key,
cpp2::IndexItem newItem;
newItem.set_index_id(oldItem.get_index_id());
newItem.set_index_name(oldItem.get_index_name());
cpp2::SchemaID schemaId;
nebula::cpp2::SchemaID schemaId;
if (oldItem.get_schema_id().getType() == meta::v1::cpp2::SchemaID::Type::tag_id) {
schemaId.set_tag_id(oldItem.get_schema_id().get_tag_id());
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/mock/AdHocIndexManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void AdHocIndexManager::addTagIndex(GraphSpaceID space,
IndexItem item;
item.set_index_id(indexID);
item.set_index_name(folly::stringPrintf("index_%d", indexID));
nebula::meta::cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
schemaID.set_tag_id(tagID);
item.set_schema_id(schemaID);
item.set_schema_name(folly::stringPrintf("tag_%d", tagID));
Expand Down Expand Up @@ -55,7 +55,7 @@ void AdHocIndexManager::addEdgeIndex(GraphSpaceID space,
IndexItem item;
item.set_index_id(indexID);
item.set_index_name(folly::stringPrintf("index_%d", indexID));
nebula::meta::cpp2::SchemaID schemaID;
nebula::cpp2::SchemaID schemaID;
schemaID.set_edge_type(edgeType);
item.set_schema_id(schemaID);
item.set_schema_name(folly::stringPrintf("edge_%d", edgeType));
Expand Down

0 comments on commit f490d4d

Please sign in to comment.