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
This commit is contained in:
Abhishek Kona 2012-11-19 10:46:36 -08:00 committed by Dhruba Borthakur
parent 65b035a47f
commit 661dc15721
1 changed files with 4 additions and 3 deletions

View File

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