Fix LDB dumpwal to print the messages as in the file.

Summary:
StringStream.clear() does not clear the stream. It sets some flags.
Who knew? Fixing that is not printing the stuff again and again.

Test Plan: ran it on a local db

Reviewers: dhruba, emayanke

Reviewed By: dhruba

Differential Revision: https://reviews.facebook.net/D6795
main
Abhishek Kona 12 years ago
parent de278a6de9
commit b648401adb
  1. 7
      util/ldb_cmd.cc

@ -390,10 +390,10 @@ void WALDumper::DoCommand() {
Slice record; Slice record;
std::stringstream row; std::stringstream row;
if (print_header_) { if (print_header_) {
std::cout<<"Sequence,Count,ByteSize\n"; std::cout<<"Sequence,Count,ByteSize,Physical Offset\n";
} }
while(reader.ReadRecord(&record, &scratch)) { while(reader.ReadRecord(&record, &scratch)) {
row.clear(); row.str("");
if (record.size() < 12) { if (record.size() < 12) {
reporter.Corruption( reporter.Corruption(
record.size(), Status::Corruption("log record too small")); record.size(), Status::Corruption("log record too small"));
@ -401,7 +401,8 @@ void WALDumper::DoCommand() {
WriteBatchInternal::SetContents(&batch, record); WriteBatchInternal::SetContents(&batch, record);
row<<WriteBatchInternal::Sequence(&batch)<<","; row<<WriteBatchInternal::Sequence(&batch)<<",";
row<<WriteBatchInternal::Count(&batch)<<","; row<<WriteBatchInternal::Count(&batch)<<",";
row<<WriteBatchInternal::ByteSize(&batch)<<"\n"; row<<WriteBatchInternal::ByteSize(&batch)<<",";
row<<reader.LastRecordOffset()<<"\n";
} }
std::cout<<row.str(); std::cout<<row.str();
} }

Loading…
Cancel
Save