[RocksDB] Improve manifest dump to print internal keys in hex for version edits.

Summary: Currently, VersionEdit::DebugString always display internal keys in the original ascii format. This could cause manifest dump to be truncated if internal keys contain special charactors (like null). Also added an option --input_key_hex for ldb idump to indicate that the passed in user keys are in hex.

Test Plan: run ldb manifest_dump

Reviewers: dhruba, emayanke

CC: leveldb

Differential Revision: https://reviews.facebook.net/D12111
This commit is contained in:
Haobo Xu
2013-08-08 15:51:16 -07:00
parent 58a0ae06dc
commit 3a3b1c3e6c
5 changed files with 17 additions and 10 deletions

View File

@@ -218,7 +218,7 @@ Status VersionEdit::DecodeFrom(const Slice& src) {
return result;
}
std::string VersionEdit::DebugString() const {
std::string VersionEdit::DebugString(bool hex_key) const {
std::string r;
r.append("VersionEdit {");
if (has_comparator_) {
@@ -245,7 +245,7 @@ std::string VersionEdit::DebugString() const {
r.append("\n CompactPointer: ");
AppendNumberTo(&r, compact_pointers_[i].first);
r.append(" ");
r.append(compact_pointers_[i].second.DebugString());
r.append(compact_pointers_[i].second.DebugString(hex_key));
}
for (DeletedFileSet::const_iterator iter = deleted_files_.begin();
iter != deleted_files_.end();
@@ -264,9 +264,9 @@ std::string VersionEdit::DebugString() const {
r.append(" ");
AppendNumberTo(&r, f.file_size);
r.append(" ");
r.append(f.smallest.DebugString());
r.append(f.smallest.DebugString(hex_key));
r.append(" .. ");
r.append(f.largest.DebugString());
r.append(f.largest.DebugString(hex_key));
}
r.append("\n}\n");
return r;

View File

@@ -89,7 +89,7 @@ class VersionEdit {
void EncodeTo(std::string* dst) const;
Status DecodeFrom(const Slice& src);
std::string DebugString() const;
std::string DebugString(bool hex_key = false) const;
private:
friend class VersionSet;

View File

@@ -1496,7 +1496,7 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname,
// Write out each individual edit
if (verbose) {
printf("*************************Edit[%d] = %s\n",
count, edit.DebugString().c_str());
count, edit.DebugString(hex).c_str());
}
count++;