Skip to content

Commit a8b2fcf

Browse files
committed
add meta version
1 parent e1ac5dd commit a8b2fcf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/tools/meta-dump/MetaDumpTool.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,43 @@ class MetaDumper {
3333
}
3434

3535
std::string prefix;
36+
{
37+
LOG(INFO) << "------------------------------------------\n\n";
38+
LOG(INFO) << "Meta version:";
39+
enum class MetaVersion {
40+
UNKNOWN = 0,
41+
V1 = 1,
42+
V2 = 2,
43+
V3 = 3,
44+
};
45+
46+
prefix = "__meta_version__";
47+
iter->Seek(rocksdb::Slice(prefix));
48+
bool found = false;
49+
while (iter->Valid() && iter->key().starts_with(prefix)) {
50+
auto version = *reinterpret_cast<const MetaVersion*>(iter->value().data());
51+
found = true;
52+
LOG(INFO) << "Meta version=" << static_cast<int>(version);
53+
break;
54+
}
55+
56+
if (!found) {
57+
prefix = MetaKeyUtils::hostPrefix();
58+
iter->Seek(rocksdb::Slice(prefix));
59+
while (iter->Valid() && iter->key().starts_with(prefix)) {
60+
found = true;
61+
auto v1KeySize = prefix.size() + sizeof(int64_t);
62+
auto version = (iter->key().size() == v1KeySize) ? MetaVersion::V1 : MetaVersion::V3;
63+
LOG(INFO) << "Meta version=" << static_cast<int>(version);
64+
iter->Next();
65+
break;
66+
}
67+
68+
if (!found) {
69+
LOG(INFO) << "Meta version= Unkown";
70+
}
71+
}
72+
}
3673
{
3774
LOG(INFO) << "------------------------------------------\n\n";
3875
LOG(INFO) << "Space info:";

0 commit comments

Comments
 (0)