From fa88cbc71e52d2c7c4d09c42a5bce24774482d9e Mon Sep 17 00:00:00 2001 From: Vamsi Ponnekanti Date: Tue, 3 Dec 2013 23:16:36 -0800 Subject: [PATCH] [Log dumper broken when merge operator is in log] Summary: $title Test Plan: on my dev box Revert Plan: OK Task ID: # Reviewers: emayanke, dhruba, haobo Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D14451 --- util/ldb_cmd.cc | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/util/ldb_cmd.cc b/util/ldb_cmd.cc index e255f81966..58d81460e9 100644 --- a/util/ldb_cmd.cc +++ b/util/ldb_cmd.cc @@ -1226,25 +1226,41 @@ void ChangeCompactionStyleCommand::DoCommand() { class InMemoryHandler : public WriteBatch::Handler { public: + InMemoryHandler(stringstream& row, bool print_values) : Handler(),row_(row) { + print_values_ = print_values; + } + + void commonPutMerge(const Slice& key, const Slice& value) { + string k = LDBCommand::StringToHex(key.ToString()); + if (print_values_) { + string v = LDBCommand::StringToHex(value.ToString()); + row_ << k << " : "; + row_ << v << " "; + } else { + row_ << k << " "; + } + } virtual void Put(const Slice& key, const Slice& value) { - putMap_[key.ToString()] = value.ToString(); + row_ << "PUT : "; + commonPutMerge(key, value); } + + virtual void Merge(const Slice& key, const Slice& value) { + row_ << "MERGE : "; + commonPutMerge(key, value); + } + virtual void Delete(const Slice& key) { - deleteList_.push_back(key.ToString(true)); + row_ <<",DELETE : "; + row_ << LDBCommand::StringToHex(key.ToString()) << " "; } + virtual ~InMemoryHandler() { }; - map PutMap() { - return putMap_; - } - vector DeleteList() { - return deleteList_; - } - private: - map putMap_; - vector deleteList_; + stringstream & row_; + bool print_values_; }; const string WALDumperCommand::ARG_WAL_FILE = "walfile"; @@ -1322,26 +1338,8 @@ void WALDumperCommand::DoCommand() { row<