Fix version edit dump in json (#12703)

Summary:
**Context/Summary:**
the flag --json of manifest_dump in ldb tool has no effect
The bug may  be introduced by pr https://github.com/facebook/rocksdb/pull/8378

Pull Request resolved: https://github.com/facebook/rocksdb/pull/12703

Reviewed By: cbi42

Differential Revision: D57848094

Pulled By: ajkr

fbshipit-source-id: 3d1ce65528bf4ce9c53593a7208406ab90e8994b
This commit is contained in:
HypenZou 2024-05-28 16:44:25 -07:00 committed by Facebook GitHub Bot
parent 259f21e695
commit 8765a0f546
1 changed files with 7 additions and 6 deletions

View File

@ -364,14 +364,15 @@ class DumpManifestHandler : public VersionEditHandler {
Status ApplyVersionEdit(VersionEdit& edit, ColumnFamilyData** cfd) override {
// Write out each individual edit
if (verbose_ && !json_) {
if (json_) {
// Print out DebugStrings. Can include non-terminating null characters.
fwrite(edit.DebugString(hex_).data(), sizeof(char),
edit.DebugString(hex_).size(), stdout);
} else if (json_) {
std::string edit_dump_str = edit.DebugJSON(count_, hex_);
fwrite(edit_dump_str.data(), sizeof(char), edit_dump_str.size(), stdout);
fwrite("\n", sizeof(char), 1, stdout);
} else if (verbose_) {
// Print out DebugStrings. Can include non-terminating null characters.
fwrite(edit.DebugString(hex_).data(), sizeof(char),
edit.DebugString(hex_).size(), stdout);
std::string edit_dump_str = edit.DebugString(hex_);
fwrite(edit_dump_str.data(), sizeof(char), edit_dump_str.size(), stdout);
}
++count_;
return VersionEditHandler::ApplyVersionEdit(edit, cfd);