From 7a512f4a367aa4c2e75b53531d9b92ad37f130fe Mon Sep 17 00:00:00 2001 From: Greg Soltis Date: Thu, 22 Mar 2018 09:51:30 -0700 Subject: Add `ToString()` to `LevelDbTransaction` (#946) * Initial plumbing for leveldb local parts * Add model::BatchId * Port leveldb_key.{h,cc} * Add string StartsWith * Add leveldb_key_test.cc to the project * Revert back to using leveldb::Slice for read/describe These operations universally operate on keys obtained from leveldb so it's actually unhelpful to force all the callers to make absl::string_views from them. * Start work on ToString for transactions * Add ToString() method to LevelDbTransaction * Style * lint * Revert addition of util::StartsWith --- .../firebase/firestore/local/leveldb_transaction.cc | 20 ++++++++++++++++++++ .../firebase/firestore/local/leveldb_transaction.h | 2 ++ 2 files changed, 22 insertions(+) (limited to 'Firestore/core/src/firebase/firestore/local') diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc b/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc index af72716..4e4a313 100644 --- a/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc +++ b/Firestore/core/src/firebase/firestore/local/leveldb_transaction.cc @@ -18,6 +18,7 @@ #include +#include "Firestore/core/src/firebase/firestore/local/leveldb_key.h" #include "Firestore/core/src/firebase/firestore/util/firebase_assert.h" using leveldb::DB; @@ -206,6 +207,25 @@ void LevelDbTransaction::Commit() { status.ToString().c_str()); } +std::string LevelDbTransaction::ToString() { + std::string dest("second.length(); + bytes += change_bytes; + items += "\n - Put " + Describe(it->first) + " (" + + std::to_string(change_bytes) + " bytes)"; + } + dest += "(" + std::to_string(bytes) + " bytes):" + items + ">"; + return dest; +} + } // namespace local } // namespace firestore } // namespace firebase diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_transaction.h b/Firestore/core/src/firebase/firestore/local/leveldb_transaction.h index 015a6cb..b219a69 100644 --- a/Firestore/core/src/firebase/firestore/local/leveldb_transaction.h +++ b/Firestore/core/src/firebase/firestore/local/leveldb_transaction.h @@ -188,6 +188,8 @@ class LevelDbTransaction { */ void Commit(); + std::string ToString(); + private: leveldb::DB* db_; Mutations mutations_; -- cgit v1.2.3