Fix bug in printing values for block-based table

Summary: value is not an InternalKey, we do not need to decode it

Test Plan:
setup:

  $ ldb put --create_if_missing=true k v
  $ ldb put --db=./tmp --create_if_missing k v
  $ ldb compact --db=./tmp

before:

  $ sst_dump --command=raw --file=./tmp/000004.sst
  ...
  terminate called after throwing an instance of 'std::length_error'

after:

  $ ./sst_dump --command=raw --file=./tmp/000004.sst
  $ cat tmp/000004_dump.txt
  ...
  ASCII  k : v
  ...

Reviewers: sdong, yhchiang, IslamAbdelRahman

Reviewed By: IslamAbdelRahman

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D62301
This commit is contained in:
Andrew Kryczka 2016-08-22 10:27:50 -07:00
parent 72f8cc703c
commit ecf9003860

View File

@ -1982,18 +1982,17 @@ Status BlockBasedTable::DumpDataBlocks(WritableFile* out_file) {
}
Slice key = datablock_iter->key();
Slice value = datablock_iter->value();
InternalKey ikey, iValue;
InternalKey ikey;
ikey.DecodeFrom(key);
iValue.DecodeFrom(value);
out_file->Append(" HEX ");
out_file->Append(ikey.user_key().ToString(true).c_str());
out_file->Append(": ");
out_file->Append(iValue.user_key().ToString(true).c_str());
out_file->Append(value.ToString(true).c_str());
out_file->Append("\n");
std::string str_key = ikey.user_key().ToString();
std::string str_value = iValue.user_key().ToString();
std::string str_value = value.ToString();
std::string res_key(""), res_value("");
char cspace = ' ';
for (size_t i = 0; i < str_key.size(); i++) {