diff --git a/src/common/utils/IndexKeyUtils.h b/src/common/utils/IndexKeyUtils.h index 1e5f6349509..c8bdd4fb967 100644 --- a/src/common/utils/IndexKeyUtils.h +++ b/src/common/utils/IndexKeyUtils.h @@ -457,7 +457,7 @@ class IndexKeyUtils final { } static VertexIDSlice getIndexVertexID(size_t vIdLen, const folly::StringPiece& rawKey) { - CHECK_GE(rawKey.size(), kVertexIndexLen + vIdLen); + CHECK_GE(rawKey.size(), kTagIndexLen + vIdLen); auto offset = rawKey.size() - vIdLen; return rawKey.subpiece(offset, vIdLen); } diff --git a/src/common/utils/NebulaKeyUtils.cpp b/src/common/utils/NebulaKeyUtils.cpp index 6445d8e88dd..9e7cc2585f7 100644 --- a/src/common/utils/NebulaKeyUtils.cpp +++ b/src/common/utils/NebulaKeyUtils.cpp @@ -34,13 +34,13 @@ std::string NebulaKeyUtils::lastKey(const std::string& prefix, size_t count) { } // static -std::string NebulaKeyUtils::vertexKey( +std::string NebulaKeyUtils::tagKey( size_t vIdLen, PartitionID partId, const VertexID& vId, TagID tagId, char pad) { CHECK_GE(vIdLen, vId.size()); - int32_t item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kVertex); + int32_t item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kTag_); std::string key; - key.reserve(kVertexLen + vIdLen); + key.reserve(kTagLen + vIdLen); key.append(reinterpret_cast(&item), sizeof(int32_t)) .append(vId.data(), vId.size()) .append(vIdLen - vId.size(), pad) @@ -106,12 +106,12 @@ std::string NebulaKeyUtils::kvKey(PartitionID partId, const folly::StringPiece& } // static -std::string NebulaKeyUtils::vertexPrefix(size_t vIdLen, - PartitionID partId, - const VertexID& vId, - TagID tagId) { +std::string NebulaKeyUtils::tagPrefix(size_t vIdLen, + PartitionID partId, + const VertexID& vId, + TagID tagId) { CHECK_GE(vIdLen, vId.size()); - PartitionID item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kVertex); + PartitionID item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kTag_); std::string key; key.reserve(sizeof(PartitionID) + vIdLen + sizeof(TagID)); @@ -123,9 +123,9 @@ std::string NebulaKeyUtils::vertexPrefix(size_t vIdLen, } // static -std::string NebulaKeyUtils::vertexPrefix(size_t vIdLen, PartitionID partId, const VertexID& vId) { +std::string NebulaKeyUtils::tagPrefix(size_t vIdLen, PartitionID partId, const VertexID& vId) { CHECK_GE(vIdLen, vId.size()); - PartitionID item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kVertex); + PartitionID item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kTag_); std::string key; key.reserve(sizeof(PartitionID) + vIdLen); key.append(reinterpret_cast(&item), sizeof(PartitionID)) @@ -135,8 +135,8 @@ std::string NebulaKeyUtils::vertexPrefix(size_t vIdLen, PartitionID partId, cons } // static -std::string NebulaKeyUtils::vertexPrefix(PartitionID partId) { - PartitionID item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kVertex); +std::string NebulaKeyUtils::tagPrefix(PartitionID partId) { + PartitionID item = (partId << kPartitionOffset) | static_cast(NebulaKeyType::kTag_); std::string key; key.reserve(sizeof(PartitionID)); key.append(reinterpret_cast(&item), sizeof(PartitionID)); @@ -210,7 +210,7 @@ std::vector NebulaKeyUtils::snapshotPrefix(PartitionID partId) { if (partId == 0) { result.emplace_back(""); } else { - result.emplace_back(vertexPrefix(partId)); + result.emplace_back(tagPrefix(partId)); result.emplace_back(edgePrefix(partId)); result.emplace_back(IndexKeyUtils::indexPrefix(partId)); // kSystem will be written when balance data diff --git a/src/common/utils/NebulaKeyUtils.h b/src/common/utils/NebulaKeyUtils.h index 5dc5904c2bf..f616e12b0d2 100644 --- a/src/common/utils/NebulaKeyUtils.h +++ b/src/common/utils/NebulaKeyUtils.h @@ -11,7 +11,7 @@ namespace nebula { /** - * VertexKeyUtils: + * TagKeyUtils: * type(1) + partId(3) + vertexId(*) + tagId(4) * * EdgeKeyUtils: @@ -55,7 +55,7 @@ class NebulaKeyUtils final { /** * Generate vertex key for kv store * */ - static std::string vertexKey( + static std::string tagKey( size_t vIdLen, PartitionID partId, const VertexID& vId, TagID tagId, char pad = '\0'); static std::string edgeKey(size_t vIdLen, @@ -75,14 +75,11 @@ class NebulaKeyUtils final { /** * Prefix for vertex * */ - static std::string vertexPrefix(size_t vIdLen, - PartitionID partId, - const VertexID& vId, - TagID tagId); + static std::string tagPrefix(size_t vIdLen, PartitionID partId, const VertexID& vId, TagID tagId); - static std::string vertexPrefix(size_t vIdLen, PartitionID partId, const VertexID& vId); + static std::string tagPrefix(size_t vIdLen, PartitionID partId, const VertexID& vId); - static std::string vertexPrefix(PartitionID partId); + static std::string tagPrefix(PartitionID partId); /** * Prefix for edge @@ -111,26 +108,26 @@ class NebulaKeyUtils final { return readInt(rawKey.data(), sizeof(PartitionID)) >> 8; } - static bool isVertex(size_t vIdLen, const folly::StringPiece& rawKey) { - if (rawKey.size() != kVertexLen + vIdLen) { + static bool isTag(size_t vIdLen, const folly::StringPiece& rawKey) { + if (rawKey.size() != kTagLen + vIdLen) { return false; } constexpr int32_t len = static_cast(sizeof(NebulaKeyType)); auto type = readInt(rawKey.data(), len) & kTypeMask; - return static_cast(type) == NebulaKeyType::kVertex; + return static_cast(type) == NebulaKeyType::kTag_; } static VertexIDSlice getVertexId(size_t vIdLen, const folly::StringPiece& rawKey) { - if (rawKey.size() != kVertexLen + vIdLen) { - dumpBadKey(rawKey, kVertexLen + vIdLen, vIdLen); + if (rawKey.size() != kTagLen + vIdLen) { + dumpBadKey(rawKey, kTagLen + vIdLen, vIdLen); } auto offset = sizeof(PartitionID); return rawKey.subpiece(offset, vIdLen); } static TagID getTagId(size_t vIdLen, const folly::StringPiece& rawKey) { - if (rawKey.size() != kVertexLen + vIdLen) { - dumpBadKey(rawKey, kVertexLen + vIdLen, vIdLen); + if (rawKey.size() != kTagLen + vIdLen) { + dumpBadKey(rawKey, kTagLen + vIdLen, vIdLen); } auto offset = sizeof(PartitionID) + vIdLen; return readInt(rawKey.data() + offset, sizeof(TagID)); diff --git a/src/common/utils/Types.h b/src/common/utils/Types.h index 1546cd537ee..8012ac91305 100644 --- a/src/common/utils/Types.h +++ b/src/common/utils/Types.h @@ -12,12 +12,13 @@ namespace nebula { enum class NebulaKeyType : uint32_t { - kVertex = 0x00000001, + kTag_ = 0x00000001, kEdge = 0x00000002, kIndex = 0x00000003, kSystem = 0x00000004, kOperation = 0x00000005, kKeyValue = 0x00000006, + // kVertex = 0x00000007, }; enum class NebulaSystemKeyType : uint32_t { @@ -41,7 +42,7 @@ static typename std::enable_if::value, T>::type readInt(cons } // size of vertex key except vertexId -static constexpr int32_t kVertexLen = sizeof(PartitionID) + sizeof(TagID); +static constexpr int32_t kTagLen = sizeof(PartitionID) + sizeof(TagID); // size of vertex key except srcId and dstId static constexpr int32_t kEdgeLen = @@ -56,7 +57,7 @@ static constexpr uint8_t kPartitionOffset = 8; // See KeyType enum static constexpr uint32_t kTypeMask = 0x000000FF; -static constexpr int32_t kVertexIndexLen = sizeof(PartitionID) + sizeof(IndexID); +static constexpr int32_t kTagIndexLen = sizeof(PartitionID) + sizeof(IndexID); static constexpr int32_t kEdgeIndexLen = sizeof(PartitionID) + sizeof(IndexID) + sizeof(EdgeRanking); diff --git a/src/common/utils/test/NebulaKeyUtilsTest.cpp b/src/common/utils/test/NebulaKeyUtilsTest.cpp index eb5504225b2..206d756daab 100644 --- a/src/common/utils/test/NebulaKeyUtilsTest.cpp +++ b/src/common/utils/test/NebulaKeyUtilsTest.cpp @@ -16,18 +16,18 @@ class KeyUtilsTestBase : public ::testing::Test { ~KeyUtilsTestBase() = default; - void verifyVertex(PartitionID partId, VertexID vId, TagID tagId, size_t actualSize) { - auto vertexKey = NebulaKeyUtils::vertexKey(vIdLen_, partId, vId, tagId); - ASSERT_EQ(vertexKey.size(), kVertexLen + vIdLen_); - ASSERT_EQ(vertexKey.substr(0, sizeof(PartitionID) + vIdLen_ + sizeof(TagID)), - NebulaKeyUtils::vertexPrefix(vIdLen_, partId, vId, tagId)); - ASSERT_EQ(vertexKey.substr(0, sizeof(PartitionID) + vIdLen_), - NebulaKeyUtils::vertexPrefix(vIdLen_, partId, vId)); - ASSERT_TRUE(NebulaKeyUtils::isVertex(vIdLen_, vertexKey)); - ASSERT_FALSE(NebulaKeyUtils::isEdge(vIdLen_, vertexKey)); - ASSERT_EQ(partId, NebulaKeyUtils::getPart(vertexKey)); - ASSERT_EQ(tagId, NebulaKeyUtils::getTagId(vIdLen_, vertexKey)); - ASSERT_EQ(vId, NebulaKeyUtils::getVertexId(vIdLen_, vertexKey).subpiece(0, actualSize)); + void verifyTag(PartitionID partId, VertexID vId, TagID tagId, size_t actualSize) { + auto tagKey = NebulaKeyUtils::tagKey(vIdLen_, partId, vId, tagId); + ASSERT_EQ(tagKey.size(), kTagLen + vIdLen_); + ASSERT_EQ(tagKey.substr(0, sizeof(PartitionID) + vIdLen_ + sizeof(TagID)), + NebulaKeyUtils::tagPrefix(vIdLen_, partId, vId, tagId)); + ASSERT_EQ(tagKey.substr(0, sizeof(PartitionID) + vIdLen_), + NebulaKeyUtils::tagPrefix(vIdLen_, partId, vId)); + ASSERT_TRUE(NebulaKeyUtils::isTag(vIdLen_, tagKey)); + ASSERT_FALSE(NebulaKeyUtils::isEdge(vIdLen_, tagKey)); + ASSERT_EQ(partId, NebulaKeyUtils::getPart(tagKey)); + ASSERT_EQ(tagId, NebulaKeyUtils::getTagId(vIdLen_, tagKey)); + ASSERT_EQ(vId, NebulaKeyUtils::getVertexId(vIdLen_, tagKey).subpiece(0, actualSize)); } void verifyEdge(PartitionID partId, @@ -47,7 +47,7 @@ class KeyUtilsTestBase : public ::testing::Test { 0, sizeof(PartitionID) + (vIdLen_ << 1) + sizeof(EdgeType) + sizeof(EdgeRanking)), NebulaKeyUtils::edgePrefix(vIdLen_, partId, srcId, type, rank, dstId)); ASSERT_TRUE(NebulaKeyUtils::isEdge(vIdLen_, edgeKey)); - ASSERT_FALSE(NebulaKeyUtils::isVertex(vIdLen_, edgeKey)); + ASSERT_FALSE(NebulaKeyUtils::isTag(vIdLen_, edgeKey)); ASSERT_EQ(partId, NebulaKeyUtils::getPart(edgeKey)); ASSERT_EQ(srcId, NebulaKeyUtils::getSrcId(vIdLen_, edgeKey).subpiece(0, actualSize)); ASSERT_EQ(dstId, NebulaKeyUtils::getDstId(vIdLen_, edgeKey).subpiece(0, actualSize)); @@ -85,7 +85,7 @@ TEST_F(V1Test, SimpleTest) { VertexID vId = getStringId(1001L); TagID tagId = 2020; TagVersion tagVersion = folly::Random::rand64(); - verifyVertex(partId, vId, tagId, tagVersion); + verifyTag(partId, vId, tagId, tagVersion); VertexID srcId = getStringId(1001L), dstId = getStringId(2001L); EdgeType type = 1010; @@ -98,7 +98,7 @@ TEST_F(V1Test, NegativeEdgeTypeTest) { PartitionID partId = 123; VertexID vId = getStringId(1001L); TagID tagId = 2020; - verifyVertex(partId, vId, tagId, sizeof(int64_t)); + verifyTag(partId, vId, tagId, sizeof(int64_t)); VertexID srcId = getStringId(1001L), dstId = getStringId(2001L); EdgeType type = -1010; @@ -111,7 +111,7 @@ TEST_F(V2ShortTest, SimpleTest) { PartitionID partId = 123; VertexID vId = "0123456789"; TagID tagId = 2020; - verifyVertex(partId, vId, tagId, 10); + verifyTag(partId, vId, tagId, 10); VertexID srcId = "0123456789", dstId = "9876543210"; EdgeType type = 1010; @@ -124,7 +124,7 @@ TEST_F(V2ShortTest, NegativeEdgeTypeTest) { PartitionID partId = 123; VertexID vId = "0123456789"; TagID tagId = 2020; - verifyVertex(partId, vId, tagId, 10); + verifyTag(partId, vId, tagId, 10); VertexID srcId = "0123456789", dstId = "9876543210"; EdgeType type = -1010; @@ -137,7 +137,7 @@ TEST_F(V2LongTest, SimpleTest) { PartitionID partId = 123; VertexID vId = "0123456789"; TagID tagId = 2020; - verifyVertex(partId, vId, tagId, 10); + verifyTag(partId, vId, tagId, 10); VertexID srcId = "0123456789", dstId = "9876543210"; EdgeType type = 1010; @@ -150,7 +150,7 @@ TEST_F(V2LongTest, NegativeEdgeTypeTest) { PartitionID partId = 123; VertexID vId = "0123456789"; TagID tagId = 2020; - verifyVertex(partId, vId, tagId, 10); + verifyTag(partId, vId, tagId, 10); VertexID srcId = "0123456789", dstId = "9876543210"; EdgeType type = -1010; diff --git a/src/kvstore/Part.cpp b/src/kvstore/Part.cpp index feb83df0768..8d8526904c1 100644 --- a/src/kvstore/Part.cpp +++ b/src/kvstore/Part.cpp @@ -457,7 +457,7 @@ bool Part::preProcessLog(LogID logId, TermID termId, ClusterID clusterId, const void Part::cleanup() { LOG(INFO) << idStr_ << "Clean rocksdb part data"; // Remove the vertex, edge, index, systemCommitKey, operation data under the part - const auto& vertexPre = NebulaKeyUtils::vertexPrefix(partId_); + const auto& vertexPre = NebulaKeyUtils::tagPrefix(partId_); auto ret = engine_->removeRange(NebulaKeyUtils::firstKey(vertexPre, vIdLen_), NebulaKeyUtils::lastKey(vertexPre, vIdLen_)); if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) { diff --git a/src/kvstore/plugins/elasticsearch/ESListener.cpp b/src/kvstore/plugins/elasticsearch/ESListener.cpp index 0e59b5227bd..b8f8702018f 100644 --- a/src/kvstore/plugins/elasticsearch/ESListener.cpp +++ b/src/kvstore/plugins/elasticsearch/ESListener.cpp @@ -44,7 +44,7 @@ void ESListener::init() { bool ESListener::apply(const std::vector& data) { std::vector docItems; for (const auto& kv : data) { - if (!nebula::NebulaKeyUtils::isVertex(vIdLen_, kv.first) && + if (!nebula::NebulaKeyUtils::isTag(vIdLen_, kv.first) && !nebula::NebulaKeyUtils::isEdge(vIdLen_, kv.first)) { continue; } diff --git a/src/kvstore/plugins/hbase/HBaseStore.cpp b/src/kvstore/plugins/hbase/HBaseStore.cpp index 81d2577ccc2..3d2e55270db 100644 --- a/src/kvstore/plugins/hbase/HBaseStore.cpp +++ b/src/kvstore/plugins/hbase/HBaseStore.cpp @@ -45,7 +45,7 @@ std::shared_ptr HBaseStore::getSchema(GraphSpaceID SchemaVer version) { std::shared_ptr schema; folly::StringPiece rawKey = key; - if (NebulaKeyUtils::isVertex(key)) { + if (NebulaKeyUtils::isTag(key)) { TagID tagId = NebulaKeyUtils::getTagId(rawKey); if (version == -1) { version = schemaMan_->getLatestTagSchemaVersion(spaceId, tagId).value(); diff --git a/src/kvstore/plugins/hbase/test/HBaseStoreTest.cpp b/src/kvstore/plugins/hbase/test/HBaseStoreTest.cpp index 94fddde5c9e..d4903503875 100644 --- a/src/kvstore/plugins/hbase/test/HBaseStoreTest.cpp +++ b/src/kvstore/plugins/hbase/test/HBaseStoreTest.cpp @@ -93,7 +93,7 @@ TEST(HBaseStoreTest, SimpleTest) { } EXPECT_EQ(expectedTotal, num); }; - std::string prefix1 = NebulaKeyUtils::vertexPrefix(partId, srcId); + std::string prefix1 = NebulaKeyUtils::tagPrefix(partId, srcId); checkPrefix(prefix1, 0, 20); std::string prefix2 = NebulaKeyUtils::edgePrefix(partId, srcId, edgeType); checkPrefix(prefix2, 0, 10); diff --git a/src/kvstore/test/NebulaListenerTest.cpp b/src/kvstore/test/NebulaListenerTest.cpp index 5d996625dd8..c02e925beb6 100644 --- a/src/kvstore/test/NebulaListenerTest.cpp +++ b/src/kvstore/test/NebulaListenerTest.cpp @@ -510,7 +510,7 @@ TEST_P(ListenerAdvanceTest, ListenerResetBySnapshotTest) { for (int32_t i = 0; i < 10; i++) { std::vector data; for (int32_t j = 0; j < 1000; j++) { - auto vKey = NebulaKeyUtils::vertexKey(8, partId, folly::to(i * 1000 + j), 5); + auto vKey = NebulaKeyUtils::tagKey(8, partId, folly::to(i * 1000 + j), 5); data.emplace_back(std::move(vKey), folly::stringPrintf("val_%d_%d", partId, i * 1000 + j)); } auto leader = findLeader(partId); @@ -584,7 +584,7 @@ TEST_P(ListenerSnapshotTest, SnapshotRateLimitTest) { for (int32_t i = 0; i < 10; i++) { std::vector data; for (int32_t j = 0; j < 1000; j++) { - auto vKey = NebulaKeyUtils::vertexKey(8, partId, folly::to(i * 1000 + j), 5); + auto vKey = NebulaKeyUtils::tagKey(8, partId, folly::to(i * 1000 + j), 5); data.emplace_back(std::move(vKey), std::string(24, 'X')); } auto leader = findLeader(partId); diff --git a/src/kvstore/test/NebulaStoreTest.cpp b/src/kvstore/test/NebulaStoreTest.cpp index 5eae7d68b19..ec8a4e56a91 100644 --- a/src/kvstore/test/NebulaStoreTest.cpp +++ b/src/kvstore/test/NebulaStoreTest.cpp @@ -950,7 +950,7 @@ TEST(NebulaStoreTest, BackupRestoreTest) { if (insertData) { std::vector data; for (auto tagId = 0; tagId < 10; tagId++) { - data.emplace_back(NebulaKeyUtils::vertexKey(vIdLen, partId, "vertex", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(vIdLen, partId, "vertex", tagId), folly::stringPrintf("val_%d", tagId)); } folly::Baton baton; @@ -962,7 +962,7 @@ TEST(NebulaStoreTest, BackupRestoreTest) { } { - std::string prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, "vertex"); + std::string prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, "vertex"); std::unique_ptr iter; auto code = store->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); diff --git a/src/kvstore/test/PartTest.cpp b/src/kvstore/test/PartTest.cpp index 53ea164b16d..900f7bc8357 100644 --- a/src/kvstore/test/PartTest.cpp +++ b/src/kvstore/test/PartTest.cpp @@ -23,7 +23,7 @@ void checkVertexData(RocksEngine* engine, PartitionID partId, int expectNum, bool checkVal = false) { - std::string vertexPrefix = NebulaKeyUtils::vertexPrefix(partId); + std::string vertexPrefix = NebulaKeyUtils::tagPrefix(partId); std::unique_ptr iter; auto code = engine->prefix(vertexPrefix, &iter); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -105,16 +105,16 @@ TEST(PartTest, KeyOrderTest) { // build vertex data in part 1, 2 while (partId < 3) { - auto key1 = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, "", 0); + auto key1 = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, "", 0); data.emplace_back(key1, folly::stringPrintf("val%d", 1)); - auto key2 = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, "", INT_MAX); + auto key2 = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, "", INT_MAX); data.emplace_back(key2, folly::stringPrintf("val%d", 2)); - auto key3 = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, "ffffff", INT_MAX, '\377'); + auto key3 = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, "ffffff", INT_MAX, '\377'); data.emplace_back(key3, folly::stringPrintf("val%d", 3)); - auto key4 = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, "", INT_MAX, '\377'); + auto key4 = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, "", INT_MAX, '\377'); data.emplace_back(key4, folly::stringPrintf("val%d", 4)); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, engine->multiPut(data)); @@ -141,12 +141,12 @@ TEST(PartTest, PartCleanTest) { while (partId < 3) { TagID tagId = 1; for (int i = 0; i < 10; i++) { - auto key = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, std::to_string(i), tagId); + auto key = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, std::to_string(i), tagId); data.emplace_back(key, folly::stringPrintf("val%d", i)); } tagId = 2; for (int i = 0; i < 10; i++) { - auto key = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, std::to_string(i), tagId); + auto key = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, std::to_string(i), tagId); data.emplace_back(key, folly::stringPrintf("val%d", i)); } @@ -196,7 +196,7 @@ TEST(PartTest, PartCleanTest) { // remove range part::clean data partId = 1; - const auto& vertexPre = NebulaKeyUtils::vertexPrefix(partId); + const auto& vertexPre = NebulaKeyUtils::tagPrefix(partId); auto ret = engine->removeRange(NebulaKeyUtils::firstKey(vertexPre, kDefaultVIdLen), NebulaKeyUtils::lastKey(vertexPre, kDefaultVIdLen)); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); diff --git a/src/kvstore/test/RocksEngineTest.cpp b/src/kvstore/test/RocksEngineTest.cpp index 9d325102bf4..a09264429d1 100644 --- a/src/kvstore/test/RocksEngineTest.cpp +++ b/src/kvstore/test/RocksEngineTest.cpp @@ -304,13 +304,13 @@ TEST_P(RocksEngineTest, VertexWholeKeyBloomFilterTest) { auto writeVertex = [&](TagID tagId) { std::vector data; - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, vId, tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, vId, tagId), folly::stringPrintf("val_%d", tagId)); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, engine->multiPut(std::move(data))); }; auto readVertex = [&](TagID tagId) { - auto key = NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, vId, tagId); + auto key = NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, vId, tagId); std::string val; auto ret = engine->get(key, &val); if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) { @@ -321,7 +321,7 @@ TEST_P(RocksEngineTest, VertexWholeKeyBloomFilterTest) { }; auto scanVertex = [&](VertexID id) { - auto prefix = NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, partId, id); + auto prefix = NebulaKeyUtils::tagPrefix(kDefaultVIdLen, partId, id); std::unique_ptr iter; auto ret = engine->prefix(prefix, &iter); EXPECT_EQ(ret, nebula::cpp2::ErrorCode::SUCCEEDED); @@ -451,13 +451,13 @@ TEST_P(RocksEngineTest, PrefixBloomTest) { std::vector data; for (auto tagId = 0; tagId < 10; tagId++) { - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 1, "1", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 1, "1", tagId), folly::stringPrintf("val_%d", tagId)); - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 1, "2", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 1, "2", tagId), folly::stringPrintf("val_%d", tagId)); - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 2, "3", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 2, "3", tagId), folly::stringPrintf("val_%d", tagId)); - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 2, "4", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 2, "4", tagId), folly::stringPrintf("val_%d", tagId)); } data.emplace_back(NebulaKeyUtils::systemCommitKey(1), "123"); @@ -467,7 +467,7 @@ TEST_P(RocksEngineTest, PrefixBloomTest) { { // vertexPrefix(partId) will not be included auto checkVertexPrefix = [&](PartitionID partId, const VertexID& vId) { - std::string prefix = NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, partId, vId); + std::string prefix = NebulaKeyUtils::tagPrefix(kDefaultVIdLen, partId, vId); std::unique_ptr iter; auto code = engine->prefix(prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -486,7 +486,7 @@ TEST_P(RocksEngineTest, PrefixBloomTest) { { // vertexPrefix(partId) will be included auto checkPartPrefix = [&](PartitionID partId) { - std::string prefix = NebulaKeyUtils::vertexPrefix(partId); + std::string prefix = NebulaKeyUtils::tagPrefix(partId); std::unique_ptr iter; auto code = engine->prefix(prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -503,7 +503,7 @@ TEST_P(RocksEngineTest, PrefixBloomTest) { { // vertexPrefix(partId) will be included auto checkRangeWithPartPrefix = [&](PartitionID partId) { - std::string prefix = NebulaKeyUtils::vertexPrefix(partId); + std::string prefix = NebulaKeyUtils::tagPrefix(partId); std::unique_ptr iter; auto code = engine->rangeWithPrefix(prefix, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -578,7 +578,7 @@ TEST(PlainTableTest, BackupRestoreWithData) { PartitionID partId = 1; auto checkData = [&] { - std::string prefix = NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, partId, "vertex"); + std::string prefix = NebulaKeyUtils::tagPrefix(kDefaultVIdLen, partId, "vertex"); std::unique_ptr iter; auto code = engine->prefix(prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -598,7 +598,7 @@ TEST(PlainTableTest, BackupRestoreWithData) { LOG(INFO) << "Write some data"; std::vector data; for (auto tagId = 0; tagId < 10; tagId++) { - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, partId, "vertex", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, partId, "vertex", tagId), folly::stringPrintf("val_%d", tagId)); } data.emplace_back(NebulaKeyUtils::systemCommitKey(partId), "123"); @@ -635,7 +635,7 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { auto checkData = [&] { auto checkVertexPrefix = [&](PartitionID partId, VertexID vId) { { - std::string prefix = NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, partId, vId); + std::string prefix = NebulaKeyUtils::tagPrefix(kDefaultVIdLen, partId, vId); std::unique_ptr iter; auto code = engine->prefix(prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -647,7 +647,7 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { EXPECT_EQ(num, 10); } for (TagID tagId = 0; tagId < 10; tagId++) { - std::string prefix = NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, partId, vId, tagId); + std::string prefix = NebulaKeyUtils::tagPrefix(kDefaultVIdLen, partId, vId, tagId); std::unique_ptr iter; auto code = engine->prefix(prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -688,7 +688,7 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { }; auto checkVertexPartPrefix = [&](PartitionID partId) { - std::string prefix = NebulaKeyUtils::vertexPrefix(partId); + std::string prefix = NebulaKeyUtils::tagPrefix(partId); std::unique_ptr iter; auto code = engine->prefix(prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -714,7 +714,7 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { }; auto checkRangeWithPartPrefix = [&](PartitionID partId) { - std::string prefix = NebulaKeyUtils::vertexPrefix(partId); + std::string prefix = NebulaKeyUtils::tagPrefix(partId); std::unique_ptr iter; auto code = engine->rangeWithPrefix(prefix, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); @@ -762,13 +762,13 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { LOG(INFO) << "Write some data"; std::vector data; for (TagID tagId = 0; tagId < 10; tagId++) { - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 1, "1", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 1, "1", tagId), folly::stringPrintf("val_%d", tagId)); - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 1, "2", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 1, "2", tagId), folly::stringPrintf("val_%d", tagId)); - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 2, "3", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 2, "3", tagId), folly::stringPrintf("val_%d", tagId)); - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 2, "4", tagId), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 2, "4", tagId), folly::stringPrintf("val_%d", tagId)); } EdgeRanking rank = 0; @@ -790,7 +790,7 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { auto writeNewData = [&engine] { std::vector data; - data.emplace_back(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 3, "5", 0), + data.emplace_back(NebulaKeyUtils::tagKey(kDefaultVIdLen, 3, "5", 0), "vertex_data_after_enable_prefix_bloom_filter"); data.emplace_back(NebulaKeyUtils::edgeKey(kDefaultVIdLen, 3, "5", 0, 0, "5"), "edge_data_after_enable_prefix_bloom_filter"); @@ -800,7 +800,7 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { auto checkNewData = [&engine] { std::string value; - auto code = engine->get(NebulaKeyUtils::vertexKey(kDefaultVIdLen, 3, "5", 0), &value); + auto code = engine->get(NebulaKeyUtils::tagKey(kDefaultVIdLen, 3, "5", 0), &value); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, code); EXPECT_EQ("vertex_data_after_enable_prefix_bloom_filter", value); code = engine->get(NebulaKeyUtils::edgeKey(kDefaultVIdLen, 3, "5", 0, 0, "5"), &value); @@ -818,9 +818,9 @@ TEST(RebuildPrefixBloomFilter, RebuildPrefixBloomFilter) { EXPECT_EQ(num, 1); }; - checkPrefix(NebulaKeyUtils::vertexPrefix(3)); - checkPrefix(NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, 3, "5")); - checkPrefix(NebulaKeyUtils::vertexPrefix(kDefaultVIdLen, 3, "5", 0)); + checkPrefix(NebulaKeyUtils::tagPrefix(3)); + checkPrefix(NebulaKeyUtils::tagPrefix(kDefaultVIdLen, 3, "5")); + checkPrefix(NebulaKeyUtils::tagPrefix(kDefaultVIdLen, 3, "5", 0)); checkPrefix(NebulaKeyUtils::edgePrefix(3)); checkPrefix(NebulaKeyUtils::edgePrefix(kDefaultVIdLen, 3, "5")); checkPrefix(NebulaKeyUtils::edgePrefix(kDefaultVIdLen, 3, "5", 0)); diff --git a/src/storage/CompactionFilter.h b/src/storage/CompactionFilter.h index f035ac3fa6a..6f95e3675fd 100644 --- a/src/storage/CompactionFilter.h +++ b/src/storage/CompactionFilter.h @@ -37,7 +37,7 @@ class StorageCompactionFilter final : public kvstore::KVFilter { return false; } - if (NebulaKeyUtils::isVertex(vIdLen_, key)) { + if (NebulaKeyUtils::isTag(vIdLen_, key)) { return !vertexValid(spaceId, key, val); } else if (NebulaKeyUtils::isEdge(vIdLen_, key)) { return !edgeValid(spaceId, key, val); diff --git a/src/storage/admin/RebuildTagIndexTask.cpp b/src/storage/admin/RebuildTagIndexTask.cpp index bc16b39eb81..4368d707053 100644 --- a/src/storage/admin/RebuildTagIndexTask.cpp +++ b/src/storage/admin/RebuildTagIndexTask.cpp @@ -52,7 +52,7 @@ nebula::cpp2::ErrorCode RebuildTagIndexTask::buildIndexGlobal(GraphSpaceID space auto vidSize = vidSizeRet.value(); std::unique_ptr iter; - auto prefix = NebulaKeyUtils::vertexPrefix(part); + auto prefix = NebulaKeyUtils::tagPrefix(part); auto ret = env_->kvstore_->prefix(space, part, prefix, &iter); if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) { LOG(ERROR) << "Processing Part " << part << " Failed"; diff --git a/src/storage/admin/StatsTask.cpp b/src/storage/admin/StatsTask.cpp index 91774fc8b5b..cf4d56811a6 100644 --- a/src/storage/admin/StatsTask.cpp +++ b/src/storage/admin/StatsTask.cpp @@ -96,7 +96,7 @@ nebula::cpp2::ErrorCode StatsTask::genSubTask(GraphSpaceID spaceId, auto partitionNum = partitionNumRet.value(); LOG(INFO) << "Start statis task"; CHECK_NOTNULL(env_->kvstore_); - auto vertexPrefix = NebulaKeyUtils::vertexPrefix(part); + auto vertexPrefix = NebulaKeyUtils::tagPrefix(part); std::unique_ptr vertexIter; auto edgePrefix = NebulaKeyUtils::edgePrefix(part); std::unique_ptr edgeIter; diff --git a/src/storage/exec/IndexVertexScanNode.cpp b/src/storage/exec/IndexVertexScanNode.cpp index 499a4d59d8a..aa87a063301 100644 --- a/src/storage/exec/IndexVertexScanNode.cpp +++ b/src/storage/exec/IndexVertexScanNode.cpp @@ -53,10 +53,10 @@ ::nebula::cpp2::ErrorCode IndexVertexScanNode::init(InitContext& ctx) { nebula::cpp2::ErrorCode IndexVertexScanNode::getBaseData(folly::StringPiece key, std::pair& kv) { - kv.first = NebulaKeyUtils::vertexKey(context_->vIdLen(), - partId_, - key.subpiece(key.size() - context_->vIdLen()).toString(), - context_->tagId_); + kv.first = NebulaKeyUtils::tagKey(context_->vIdLen(), + partId_, + key.subpiece(key.size() - context_->vIdLen()).toString(), + context_->tagId_); return kvstore_->get(context_->spaceId(), partId_, kv.first, &kv.second); } diff --git a/src/storage/exec/ScanNode.h b/src/storage/exec/ScanNode.h index 3778eb87804..5af7912f758 100644 --- a/src/storage/exec/ScanNode.h +++ b/src/storage/exec/ScanNode.h @@ -43,7 +43,7 @@ class ScanVertexPropNode : public QueryNode { } std::string start; - std::string prefix = NebulaKeyUtils::vertexPrefix(partId); + std::string prefix = NebulaKeyUtils::tagPrefix(partId); if (cursor.empty()) { start = prefix; } else { diff --git a/src/storage/exec/TagNode.h b/src/storage/exec/TagNode.h index d6d597addc8..e2086738518 100644 --- a/src/storage/exec/TagNode.h +++ b/src/storage/exec/TagNode.h @@ -50,7 +50,7 @@ class TagNode final : public IterateNode { VLOG(1) << "partId " << partId << ", vId " << vId << ", tagId " << tagId_ << ", prop size " << props_->size(); - key_ = NebulaKeyUtils::vertexKey(context_->vIdLen(), partId, vId, tagId_); + key_ = NebulaKeyUtils::tagKey(context_->vIdLen(), partId, vId, tagId_); ret = context_->env()->kvstore_->get(context_->spaceId(), partId, key_, &value_); if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) { return doExecute(key_, value_); diff --git a/src/storage/exec/UpdateNode.h b/src/storage/exec/UpdateNode.h index e9ef3c9d072..21fa7153ee0 100644 --- a/src/storage/exec/UpdateNode.h +++ b/src/storage/exec/UpdateNode.h @@ -269,7 +269,7 @@ class UpdateTagNode : public UpdateNode { expCtx_->setTagProp(tagName_, p.first, p.second); } - key_ = NebulaKeyUtils::vertexKey(context_->vIdLen(), partId, vId, tagId_); + key_ = NebulaKeyUtils::tagKey(context_->vIdLen(), partId, vId, tagId_); rowWriter_ = std::make_unique(schema_); return nebula::cpp2::ErrorCode::SUCCEEDED; diff --git a/src/storage/mutate/AddVerticesProcessor.cpp b/src/storage/mutate/AddVerticesProcessor.cpp index cdd897e8373..2396014d841 100644 --- a/src/storage/mutate/AddVerticesProcessor.cpp +++ b/src/storage/mutate/AddVerticesProcessor.cpp @@ -90,7 +90,7 @@ void AddVerticesProcessor::doProcess(const cpp2::AddVerticesRequest& req) { break; } - auto key = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vid, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen_, partId, vid, tagId); if (ifNotExists_) { if (!visited.emplace(key).second) { continue; @@ -142,7 +142,7 @@ void AddVerticesProcessor::doProcessWithIndex(const cpp2::AddVerticesRequest& re dummyLock.reserve(vertices.size()); auto code = nebula::cpp2::ErrorCode::SUCCEEDED; - // cache vertexKey + // cache tagKey std::unordered_set visited; visited.reserve(vertices.size()); for (auto& vertex : vertices) { @@ -176,7 +176,7 @@ void AddVerticesProcessor::doProcessWithIndex(const cpp2::AddVerticesRequest& re break; } - auto key = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vid, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen_, partId, vid, tagId); if (ifNotExists_ && !visited.emplace(key).second) { continue; } @@ -307,7 +307,7 @@ void AddVerticesProcessor::doProcessWithIndex(const cpp2::AddVerticesRequest& re ErrorOr AddVerticesProcessor::findOldValue( PartitionID partId, const VertexID& vId, TagID tagId) { - auto key = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vId, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen_, partId, vId, tagId); std::string val; auto ret = env_->kvstore_->get(spaceId_, partId, key, &val); if (ret == nebula::cpp2::ErrorCode::SUCCEEDED) { diff --git a/src/storage/mutate/DeleteTagsProcessor.cpp b/src/storage/mutate/DeleteTagsProcessor.cpp index 5aae7132f7d..af414c55ba4 100644 --- a/src/storage/mutate/DeleteTagsProcessor.cpp +++ b/src/storage/mutate/DeleteTagsProcessor.cpp @@ -55,7 +55,7 @@ void DeleteTagsProcessor::process(const cpp2::DeleteTagsRequest& req) { for (const auto& entry : delTags) { const auto& vId = entry.get_id().getStr(); for (const auto& tagId : entry.get_tags()) { - auto key = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vId, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen_, partId, vId, tagId); keys.emplace_back(std::move(key)); } } @@ -94,7 +94,7 @@ ErrorOr DeleteTagsProcessor::deleteTags( for (const auto& entry : delTags) { const auto& vId = entry.get_id().getStr(); for (const auto& tagId : entry.get_tags()) { - auto key = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vId, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen_, partId, vId, tagId); auto tup = std::make_tuple(spaceId_, partId, tagId, vId); // ignore if there are duplicate delete if (std::find(lockedKeys.begin(), lockedKeys.end(), tup) != lockedKeys.end()) { diff --git a/src/storage/mutate/DeleteVerticesProcessor.cpp b/src/storage/mutate/DeleteVerticesProcessor.cpp index eb37ff8ce99..e9a6bae1840 100644 --- a/src/storage/mutate/DeleteVerticesProcessor.cpp +++ b/src/storage/mutate/DeleteVerticesProcessor.cpp @@ -62,7 +62,7 @@ void DeleteVerticesProcessor::process(const cpp2::DeleteVerticesRequest& req) { break; } - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid.getStr()); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid.getStr()); std::unique_ptr iter; code = env_->kvstore_->prefix(spaceId_, partId, prefix, &iter); if (code != nebula::cpp2::ErrorCode::SUCCEEDED) { @@ -112,7 +112,7 @@ ErrorOr DeleteVerticesProcessor::deleteVer target.reserve(vertices.size()); std::unique_ptr batchHolder = std::make_unique(); for (auto& vertex : vertices) { - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vertex.getStr()); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vertex.getStr()); std::unique_ptr iter; auto ret = env_->kvstore_->prefix(spaceId_, partId, prefix, &iter); if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) { diff --git a/src/storage/test/AddAndUpdateVertexAndEdgeBenchmark.cpp b/src/storage/test/AddAndUpdateVertexAndEdgeBenchmark.cpp index d5cd087c480..9a8bbc1f3b8 100644 --- a/src/storage/test/AddAndUpdateVertexAndEdgeBenchmark.cpp +++ b/src/storage/test/AddAndUpdateVertexAndEdgeBenchmark.cpp @@ -131,7 +131,7 @@ bool mockVertexData(storage::StorageEnv* ev, int32_t totalParts, int32_t vidLen, std::atomic count(1); std::vector data; - auto key = NebulaKeyUtils::vertexKey(vidLen, pId, vertex.vId_, vertex.tId_); + auto key = NebulaKeyUtils::tagKey(vidLen, pId, vertex.vId_, vertex.tId_); auto schema = ev->schemaMan_->getTagSchema(spaceId, vertex.tId_); if (!schema) { LOG(ERROR) << "Invalid tagId " << vertex.tId_; diff --git a/src/storage/test/CompactionTest.cpp b/src/storage/test/CompactionTest.cpp index c1345915513..3e6aef4ac0b 100644 --- a/src/storage/test/CompactionTest.cpp +++ b/src/storage/test/CompactionTest.cpp @@ -35,7 +35,7 @@ void checkTagVertexData(int32_t spaceVidLen, VertexID lastVertexId = ""; for (int part = 1; part <= parts; part++) { - auto prefix = NebulaKeyUtils::vertexPrefix(part); + auto prefix = NebulaKeyUtils::tagPrefix(part); auto ret = env->kvstore_->prefix(spaceId, part, prefix, &iter); ASSERT_EQ(ret, nebula::cpp2::ErrorCode::SUCCEEDED); diff --git a/src/storage/test/GetNeighborsBenchmark.cpp b/src/storage/test/GetNeighborsBenchmark.cpp index ac2157984cc..d18c97224b9 100644 --- a/src/storage/test/GetNeighborsBenchmark.cpp +++ b/src/storage/test/GetNeighborsBenchmark.cpp @@ -250,7 +250,7 @@ void prefix(int32_t iters, { // read tags std::unique_ptr iter; - auto prefix = nebula::NebulaKeyUtils::vertexPrefix(vIdLen, partId, vId, player); + auto prefix = nebula::NebulaKeyUtils::tagKey(vIdLen, partId, vId, player); auto code = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(code, nebula::cpp2::ErrorCode::SUCCEEDED); CHECK(iter->valid()); diff --git a/src/storage/test/GetPropTest.cpp b/src/storage/test/GetPropTest.cpp index 59d3bb6e442..1ed42d03a1f 100644 --- a/src/storage/test/GetPropTest.cpp +++ b/src/storage/test/GetPropTest.cpp @@ -668,7 +668,7 @@ TEST(QueryVertexPropsTest, PrefixBloomFilterTest) { for (const auto& vId : vertices) { PartitionID partId = (hash(vId) % totalParts) + 1; std::unique_ptr iter; - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, vId, player); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, vId, player); auto code = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(code, nebula::cpp2::ErrorCode::SUCCEEDED); } diff --git a/src/storage/test/IndexScanLimitTest.cpp b/src/storage/test/IndexScanLimitTest.cpp index bb57aef7ff0..83e678c0d4c 100644 --- a/src/storage/test/IndexScanLimitTest.cpp +++ b/src/storage/test/IndexScanLimitTest.cpp @@ -118,9 +118,9 @@ class IndexScanLimitTest : public ::testing::Test { std::string val = vid % 2 == 0 ? val1 : val2; auto vertex = folly::to(vid); auto edgeKey = NebulaKeyUtils::edgeKey(vertexLen, pId, vertex, edgeType, 0, vertex); - auto vertexKey = NebulaKeyUtils::vertexKey(vertexLen, pId, vertex, tagId); + auto tagKey = NebulaKeyUtils::tagKey(vertexLen, pId, vertex, tagId); data.emplace_back(std::move(edgeKey), val); - data.emplace_back(std::move(vertexKey), std::move(val)); + data.emplace_back(std::move(tagKey), std::move(val)); if (indexMan_ != nullptr) { if (indexMan_->getTagIndex(spaceId, tagIndex).ok()) { auto vertexIndexKeys = diff --git a/src/storage/test/IndexTest.cpp b/src/storage/test/IndexTest.cpp index 6c4e34ad122..2b269da938f 100644 --- a/src/storage/test/IndexTest.cpp +++ b/src/storage/test/IndexTest.cpp @@ -152,7 +152,7 @@ class IndexScanTest : public ::testing::Test { std::vector> indices) { std::vector> ret(indices.size() + 1); for (size_t i = 0; i < rows.size(); i++) { - auto key = NebulaKeyUtils::vertexKey(8, 0, std::to_string(i), tagId); + auto key = NebulaKeyUtils::tagKey(8, 0, std::to_string(i), tagId); RowWriterV2 writer(schema.get()); for (size_t j = 0; j < rows[i].size(); j++) { writer.setValue(j, rows[i][j]); diff --git a/src/storage/test/IndexWithTTLTest.cpp b/src/storage/test/IndexWithTTLTest.cpp index 0d61c3248de..88c16d49737 100644 --- a/src/storage/test/IndexWithTTLTest.cpp +++ b/src/storage/test/IndexWithTTLTest.cpp @@ -164,7 +164,7 @@ TEST(IndexWithTTLTest, AddVerticesIndexWithTTL) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -184,7 +184,7 @@ TEST(IndexWithTTLTest, AddVerticesIndexWithTTL) { LOG(INFO) << "Check data after compaction ..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(0, retNum); } @@ -258,7 +258,7 @@ TEST(IndexWithTTLTest, UpdateVerticesIndexWithTTL) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -302,7 +302,7 @@ TEST(IndexWithTTLTest, UpdateVerticesIndexWithTTL) { LOG(INFO) << "Check data after update ..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -405,7 +405,7 @@ TEST(IndexWithTTLTest, RebuildTagIndexWithTTL) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -448,7 +448,7 @@ TEST(IndexWithTTLTest, RebuildTagIndexWithTTL) { LOG(INFO) << "Check data after rebuild ..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -543,7 +543,7 @@ TEST(IndexWithTTLTest, RebuildTagIndexWithTTLExpired) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -588,7 +588,7 @@ TEST(IndexWithTTLTest, RebuildTagIndexWithTTLExpired) { LOG(INFO) << "Check data after rebuild ..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } diff --git a/src/storage/test/IndexWriteTest.cpp b/src/storage/test/IndexWriteTest.cpp index 1aec5beb400..91f30a0f53d 100644 --- a/src/storage/test/IndexWriteTest.cpp +++ b/src/storage/test/IndexWriteTest.cpp @@ -91,7 +91,7 @@ TEST(IndexTest, SimpleVerticesTest) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -120,7 +120,7 @@ TEST(IndexTest, SimpleVerticesTest) { LOG(INFO) << "Check delete data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(0, retNum); } @@ -286,7 +286,7 @@ TEST(IndexTest, VerticesValueTest) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); auto retNum = verifyResultNum(1, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -398,7 +398,7 @@ TEST(IndexTest, AlterTagIndexTest) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); auto retNum = verifyResultNum(spaceId, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } @@ -460,7 +460,7 @@ TEST(IndexTest, AlterTagIndexTest) { LOG(INFO) << "Check insert data..."; for (auto partId = 1; partId <= 6; partId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, convertVertexId(vIdLen, partId)); auto retNum = verifyResultNum(spaceId, partId, prefix, env->kvstore_); EXPECT_EQ(1, retNum); } diff --git a/src/storage/test/LookupIndexTest.cpp b/src/storage/test/LookupIndexTest.cpp index 2c883faddff..4f96001b67f 100644 --- a/src/storage/test/LookupIndexTest.cpp +++ b/src/storage/test/LookupIndexTest.cpp @@ -64,7 +64,7 @@ TEST_P(LookupIndexTest, LookupIndexTestV1) { RowWriterV1 writer(schemaV1.get()); writer << true << 1L << 1.1F << 1.1F << "row1"; writer.encode(); - auto key = NebulaKeyUtils::vertexKey(vIdLen.value(), 1, vId1, 3); + auto key = NebulaKeyUtils::tagKey(vIdLen.value(), 1, vId1, 3); keyValues.emplace_back(std::move(key), writer.encode()); // setup V2 row @@ -85,7 +85,7 @@ TEST_P(LookupIndexTest, LookupIndexTestV1) { writer2.setValue("col_date", date); writer2.setValue("col_datetime", dt); writer2.finish(); - key = NebulaKeyUtils::vertexKey(vIdLen.value(), 1, vId2, 3); + key = NebulaKeyUtils::tagKey(vIdLen.value(), 1, vId2, 3); keyValues.emplace_back(std::move(key), writer2.moveEncodedStr()); // setup index key diff --git a/src/storage/test/MemoryLockBenchmark.cpp b/src/storage/test/MemoryLockBenchmark.cpp index ac1aaf6f2b6..cc33755577d 100644 --- a/src/storage/test/MemoryLockBenchmark.cpp +++ b/src/storage/test/MemoryLockBenchmark.cpp @@ -36,7 +36,7 @@ void forString(StringLock* lock, int64_t spaceId) noexcept { size_t vIdLen = 32; for (int32_t j = 0; j < FLAGS_num_batch; j++) { toLock.emplace_back(folly::to(spaceId) + - NebulaKeyUtils::vertexKey(vIdLen, j, folly::to(j), j)); + NebulaKeyUtils::tagKey(vIdLen, j, folly::to(j), j)); } nebula::MemoryLockGuard lg(lock, std::move(toLock)); } diff --git a/src/storage/test/PrefixBloomFilterBenchmark.cpp b/src/storage/test/PrefixBloomFilterBenchmark.cpp index 7140fbde060..f4f6750cccf 100644 --- a/src/storage/test/PrefixBloomFilterBenchmark.cpp +++ b/src/storage/test/PrefixBloomFilterBenchmark.cpp @@ -28,7 +28,7 @@ void mockData(StorageEnv* env, int32_t partCount) { vertexId < (partId + 1) * FLAGS_vertex_per_part; vertexId++) { for (TagID tagId = 3001; tagId < 3010; tagId++) { - auto key = NebulaKeyUtils::vertexKey(vIdLen, partId, std::to_string(vertexId), tagId); + auto key = NebulaKeyUtils::tagKey(vIdLen, partId, std::to_string(vertexId), tagId); auto val = folly::stringPrintf("%d_%d", vertexId, tagId); data.emplace_back(std::move(key), std::move(val)); } @@ -53,7 +53,7 @@ void testPrefixSeek(StorageEnv* env, int32_t partCount, int32_t iters) { for (int32_t vertexId = partId * FLAGS_vertex_per_part; vertexId < (partId + 1) * FLAGS_vertex_per_part; vertexId++) { - auto prefix = NebulaKeyUtils::vertexPrefix(vIdLen, partId, std::to_string(vertexId)); + auto prefix = NebulaKeyUtils::tagPrefix(vIdLen, partId, std::to_string(vertexId)); std::unique_ptr iter; auto code = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(code, nebula::cpp2::ErrorCode::SUCCEEDED); diff --git a/src/storage/test/QueryStatsTest.cpp b/src/storage/test/QueryStatsTest.cpp index 04d26977fbd..b8cd99ba942 100644 --- a/src/storage/test/QueryStatsTest.cpp +++ b/src/storage/test/QueryStatsTest.cpp @@ -21,7 +21,7 @@ void mockData(kvstore::KVStore* kv) { std::vector data; for (int32_t vertexId = partId * 10; vertexId < (partId + 1) * 10; vertexId++) { for (int32_t tagId = 3001; tagId < 3010; tagId++) { - auto key = NebulaKeyUtils::vertexKey(partId, vertexId, tagId, 0); + auto key = NebulaKeyUtils::tagKey(partId, vertexId, tagId, 0); auto val = TestUtils::setupEncode(3, 6); data.emplace_back(std::move(key), std::move(val)); } diff --git a/src/storage/test/QueryTestUtils.h b/src/storage/test/QueryTestUtils.h index 24556c2e1fd..5b9d5d103c3 100644 --- a/src/storage/test/QueryTestUtils.h +++ b/src/storage/test/QueryTestUtils.h @@ -45,7 +45,7 @@ class QueryTestUtils { for (const auto& vertex : vertices) { PartitionID partId = (hash(vertex.vId_) % totalParts) + 1; TagID tagId = vertex.tId_; - auto key = NebulaKeyUtils::vertexKey(spaceVidLen, partId, vertex.vId_, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen, partId, vertex.vId_, tagId); auto schema = env->schemaMan_->getTagSchema(spaceId, tagId); if (!schema) { LOG(ERROR) << "Invalid tagId " << tagId; diff --git a/src/storage/test/RebuildIndexTest.cpp b/src/storage/test/RebuildIndexTest.cpp index 8661811ea92..ec598d52849 100644 --- a/src/storage/test/RebuildIndexTest.cpp +++ b/src/storage/test/RebuildIndexTest.cpp @@ -101,7 +101,7 @@ TEST_F(RebuildIndexTest, RebuildTagIndexCheckALLData) { EXPECT_LT(0, vidSize); int dataNum = 0; for (auto part : parts) { - auto prefix = NebulaKeyUtils::vertexPrefix(part); + auto prefix = NebulaKeyUtils::tagPrefix(part); std::unique_ptr iter; auto ret = RebuildIndexTest::env_->kvstore_->prefix(1, part, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); diff --git a/src/storage/test/StatsTaskTest.cpp b/src/storage/test/StatsTaskTest.cpp index 6ba49a74f9f..f267df6eb82 100644 --- a/src/storage/test/StatsTaskTest.cpp +++ b/src/storage/test/StatsTaskTest.cpp @@ -299,7 +299,7 @@ TEST_F(StatsTaskTest, StatsTagAndEdgeData) { VertexID lastDstVertexId = ""; EdgeRanking lastRank = 0; - auto prefix = NebulaKeyUtils::vertexPrefix(part); + auto prefix = NebulaKeyUtils::tagPrefix(part); std::unique_ptr iter; auto ret = env_->kvstore_->prefix(spaceId, part, prefix, &iter); if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) { diff --git a/src/storage/test/StorageIndexWriteBenchmark.cpp b/src/storage/test/StorageIndexWriteBenchmark.cpp index 0571951f32a..dde6bdadd00 100644 --- a/src/storage/test/StorageIndexWriteBenchmark.cpp +++ b/src/storage/test/StorageIndexWriteBenchmark.cpp @@ -176,7 +176,7 @@ void initEnv(IndexENV type, } void verifyDataCount(storage::StorageEnv* env, int32_t expected) { - auto prefix = NebulaKeyUtils::vertexPrefix(1); + auto prefix = NebulaKeyUtils::tagPrefix(1); std::unique_ptr iter; auto status = env->kvstore_->prefix(spaceId, 1, prefix, &iter); DCHECK(nebula::cpp2::ErrorCode::SUCCEEDED == status); diff --git a/src/storage/test/TestUtils.h b/src/storage/test/TestUtils.h index 49a004c8454..d82bbd8ca9f 100644 --- a/src/storage/test/TestUtils.h +++ b/src/storage/test/TestUtils.h @@ -41,7 +41,7 @@ void checkAddVerticesData(cpp2::AddVerticesRequest req, for (auto& newTag : newTagVec) { auto tagId = newTag.get_tag_id(); - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vid.getStr(), tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vid.getStr(), tagId); std::unique_ptr iter; EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, env->kvstore_->prefix(spaceId, partId, prefix, &iter)); @@ -152,7 +152,7 @@ void checkVerticesData(int32_t spaceVidLen, auto partId = part.first; auto deleteVidVec = part.second; for (auto& vid : deleteVidVec) { - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vid.getStr()); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vid.getStr()); std::unique_ptr iter; EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, env->kvstore_->prefix(spaceId, partId, prefix, &iter)); diff --git a/src/storage/test/UpdateVertexTest.cpp b/src/storage/test/UpdateVertexTest.cpp index 32b3d1a9eb3..1b6558ca593 100644 --- a/src/storage/test/UpdateVertexTest.cpp +++ b/src/storage/test/UpdateVertexTest.cpp @@ -58,7 +58,7 @@ static bool mockVertexData(storage::StorageEnv* env, int32_t totalParts, int32_t data.clear(); for (const auto& vertex : part.second) { TagID tagId = vertex.tId_; - auto key = NebulaKeyUtils::vertexKey(spaceVidLen, part.first, vertex.vId_, tagId); + auto key = NebulaKeyUtils::tagKey(spaceVidLen, part.first, vertex.vId_, tagId); auto schema = env->schemaMan_->getTagSchema(spaceId, tagId); if (!schema) { LOG(ERROR) << "Invalid tagId " << tagId; @@ -184,7 +184,7 @@ TEST(UpdateVertexTest, No_Filter_Test) { EXPECT_EQ(1, (*resp.props_ref()).rows[0].values[5].getInt()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -303,7 +303,7 @@ TEST(UpdateVertexTest, Filter_Yield_Test2) { // get player from kvstore directly // Because no update, the value is old - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -406,7 +406,7 @@ TEST(UpdateVertexTest, Insertable_Test) { EXPECT_EQ(1, (*resp.props_ref()).rows[0].values[5].getInt()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -487,7 +487,7 @@ TEST(UpdateVertexTest, Invalid_Update_Prop_Test) { // get player from kvstore directly // Because no update, the value is old - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -587,7 +587,7 @@ TEST(UpdateVertexTest, Invalid_Filter_Test) { // get player from kvstore directly // Because no update, the value is old - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -704,7 +704,7 @@ TEST(UpdateVertexTest, Insertable_Filter_Value_Test) { EXPECT_EQ(1, (*resp.props_ref()).rows[0].values[5].getInt()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -737,7 +737,7 @@ TEST(UpdateVertexTest, CorruptDataTest) { auto partId = std::hash()("Lonzo Ball") % parts + 1; VertexID vertexId("Lonzo Ball"); - auto key = NebulaKeyUtils::vertexKey(spaceVidLen, partId, vertexId, 1); + auto key = NebulaKeyUtils::tagKey(spaceVidLen, partId, vertexId, 1); std::vector data; data.emplace_back(std::make_pair(key, "")); folly::Baton<> baton; @@ -954,7 +954,7 @@ TEST(UpdateVertexTest, TTL_Insert_No_Exist_Test) { EXPECT_EQ(1, (*resp.props_ref()).rows[0].values[5].getInt()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -1075,7 +1075,7 @@ TEST(UpdateVertexTest, TTL_Insert_Test) { // Get player from kvstore directly, ttl expired data can be readed // First record is inserted record data // Second record is expired ttl data - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -1256,7 +1256,7 @@ TEST(UpdateVertexTest, Insertable_In_Set_Test) { EXPECT_EQ(1, (*resp.props_ref()).rows[0].values[4].getInt()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); EXPECT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -1328,7 +1328,7 @@ TEST(UpdateVertexTest, Update_Multi_tag_Test) { EXPECT_EQ(1, (*resp.result_ref()).failed_parts.size()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -1398,7 +1398,7 @@ TEST(UpdateVertexTest, Upsert_Multi_tag_Test) { EXPECT_EQ(1, (*resp.result_ref()).failed_parts.size()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); @@ -1467,7 +1467,7 @@ TEST(UpdateVertexTest, Upsert_Field_Type_And_Value_Match_Test) { EXPECT_EQ(1, (*resp.result_ref()).failed_parts.size()); // get player from kvstore directly - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen, partId, vertexId, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen, partId, vertexId, tagId); std::unique_ptr iter; auto ret = env->kvstore_->prefix(spaceId, partId, prefix, &iter); ASSERT_EQ(nebula::cpp2::ErrorCode::SUCCEEDED, ret); diff --git a/src/tools/db-dump/DbDumper.cpp b/src/tools/db-dump/DbDumper.cpp index 3ae9d40fd0d..8be44a822e9 100644 --- a/src/tools/db-dump/DbDumper.cpp +++ b/src/tools/db-dump/DbDumper.cpp @@ -219,7 +219,7 @@ void DbDumper::run() { continue; } auto partId = metaClient_->partId(partNum_, vid); - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid); seek(prefix); } break; @@ -246,7 +246,7 @@ void DbDumper::run() { } auto partId = metaClient_->partId(partNum_, vid); for (auto tagId : tagIds_) { - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid, tagId); seek(prefix); } } @@ -271,7 +271,7 @@ void DbDumper::run() { } auto partId = metaClient_->partId(partNum_, vid); for (auto tagId : tagIds_) { - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid, tagId); seek(prefix); } } @@ -280,7 +280,7 @@ void DbDumper::run() { case 0b1000: { // specified part, seek with prefix and print them all for (auto partId : parts_) { - auto vertexPrefix = NebulaKeyUtils::vertexPrefix(partId); + auto vertexPrefix = NebulaKeyUtils::tagPrefix(partId); seek(vertexPrefix); auto edgePrefix = NebulaKeyUtils::edgePrefix(partId); seek(edgePrefix); @@ -302,7 +302,7 @@ void DbDumper::run() { beforePrintVertex_.emplace_back(printIfTagFound); beforePrintEdge_.emplace_back(noPrint); for (auto partId : parts_) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); seek(prefix); } break; @@ -321,7 +321,7 @@ void DbDumper::run() { beforePrintVertex_.emplace_back(printIfTagFound); beforePrintEdge_.emplace_back(noPrint); for (auto partId : parts_) { - auto prefix = NebulaKeyUtils::vertexPrefix(partId); + auto prefix = NebulaKeyUtils::tagPrefix(partId); seek(prefix); } break; @@ -333,7 +333,7 @@ void DbDumper::run() { if (!isValidVidLen(vid)) { continue; } - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid); seek(prefix); } } @@ -362,7 +362,7 @@ void DbDumper::run() { continue; } for (auto tagId : tagIds_) { - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid, tagId); seek(prefix); } } @@ -389,7 +389,7 @@ void DbDumper::run() { continue; } for (auto tagId : tagIds_) { - auto prefix = NebulaKeyUtils::vertexPrefix(spaceVidLen_, partId, vid, tagId); + auto prefix = NebulaKeyUtils::tagPrefix(spaceVidLen_, partId, vid, tagId); seek(prefix); } } @@ -440,7 +440,7 @@ void DbDumper::iterates(kvstore::RocksPrefixIter* it) { auto key = it->key(); auto value = it->val(); - if (NebulaKeyUtils::isVertex(spaceVidLen_, key)) { + if (NebulaKeyUtils::isTag(spaceVidLen_, key)) { // filter the data bool isFiltered = false; for (auto& cb : beforePrintVertex_) { diff --git a/src/tools/db-upgrade/DbUpgrader.cpp b/src/tools/db-upgrade/DbUpgrader.cpp index 3628cb7474f..76b8019fece 100644 --- a/src/tools/db-upgrade/DbUpgrader.cpp +++ b/src/tools/db-upgrade/DbUpgrader.cpp @@ -269,7 +269,7 @@ void UpgraderSpace::runPartV1() { auto strVid = std::string(reinterpret_cast(&vId), sizeof(vId)); auto newTagSchema = it->second.back().get(); // Generate 2.0 key - auto newKey = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, strVid, tagId); + auto newKey = NebulaKeyUtils::tagKey(spaceVidLen_, partId, strVid, tagId); auto val = iter->val(); auto reader = RowReaderWrapper::getTagPropReader(schemaMan_, spaceId_, tagId, val); if (!reader) { @@ -482,7 +482,7 @@ void UpgraderSpace::runPartV2() { auto newTagSchema = it->second.back().get(); // Generate 2.0 key - auto newKey = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vId, tagId); + auto newKey = NebulaKeyUtils::tagKey(spaceVidLen_, partId, vId, tagId); auto val = iter->val(); auto reader = RowReaderWrapper::getTagPropReader(schemaMan_, spaceId_, tagId, val); if (!reader) { diff --git a/src/tools/db-upgrade/NebulaKeyUtilsV2.cpp b/src/tools/db-upgrade/NebulaKeyUtilsV2.cpp index 4891adb3f98..8a1a0f429c6 100644 --- a/src/tools/db-upgrade/NebulaKeyUtilsV2.cpp +++ b/src/tools/db-upgrade/NebulaKeyUtilsV2.cpp @@ -16,7 +16,7 @@ bool NebulaKeyUtilsV2::isValidVidLen(size_t vIdLen, VertexID srcVId, VertexID ds } // static -std::string NebulaKeyUtilsV2::vertexKey( +std::string NebulaKeyUtilsV2::tagKey( size_t vIdLen, PartitionID partId, VertexID vId, TagID tagId, TagVersion tv) { CHECK_GE(vIdLen, vId.size()); tagId &= kTagMaskSet; diff --git a/src/tools/db-upgrade/NebulaKeyUtilsV2.h b/src/tools/db-upgrade/NebulaKeyUtilsV2.h index 1f7a79b6556..533e448ac0f 100644 --- a/src/tools/db-upgrade/NebulaKeyUtilsV2.h +++ b/src/tools/db-upgrade/NebulaKeyUtilsV2.h @@ -50,9 +50,9 @@ class NebulaKeyUtilsV2 final { static bool isValidVidLen(size_t vIdLen, VertexID srcvId, VertexID dstvId = ""); /** - * Generate vertex key for kv store + * Generate tag key for kv store * */ - static std::string vertexKey( + static std::string tagKey( size_t vIdLen, PartitionID partId, VertexID vId, TagID tagId, TagVersion tv); /**