]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/RocksDBStore:Drop buffer_list and key_list in transaction. 4928/head
authorXiaoxi Chen <xiaoxi.chen@intel.com>
Thu, 11 Jun 2015 08:11:56 +0000 (16:11 +0800)
committerXiaoxi Chen <xiaoxi.chen@intel.com>
Thu, 11 Jun 2015 08:11:56 +0000 (16:11 +0800)
We dont need to keep this inside the transaction.

Signed-off-by: Xiaoxi Chen <xiaoxi.chen@intel.com>
src/os/RocksDBStore.cc
src/os/RocksDBStore.h

index cc06bd36a9a8e3f63d4656b84082b124b2385354..ad6022d09b702b7a281b7a6f0314d16c2bfadd9b 100644 (file)
@@ -237,21 +237,19 @@ void RocksDBStore::RocksDBTransactionImpl::set(
   const string &k,
   const bufferlist &to_set_bl)
 {
-  buffers.push_back(to_set_bl);
-  bufferlist &bl = *(buffers.rbegin());
   string key = combine_strings(prefix, k);
-  keys.push_back(key);
-  bat->Delete(rocksdb::Slice(*(keys.rbegin())));
-  bat->Put(rocksdb::Slice(*(keys.rbegin())),
-         rocksdb::Slice(bl.c_str(), bl.length()));
+  //bufferlist::c_str() is non-constant, so we need to make a copy
+  bufferlist val = to_set_bl;
+  bat->Delete(rocksdb::Slice(key));
+  bat->Put(rocksdb::Slice(key),
+         rocksdb::Slice(val.c_str(), val.length()));
 }
 
 void RocksDBStore::RocksDBTransactionImpl::rmkey(const string &prefix,
                                                 const string &k)
 {
   string key = combine_strings(prefix, k);
-  keys.push_back(key);
-  bat->Delete(rocksdb::Slice(*(keys.rbegin())));
+  bat->Delete(rocksdb::Slice(k));
 }
 
 void RocksDBStore::RocksDBTransactionImpl::rmkeys_by_prefix(const string &prefix)
@@ -261,8 +259,7 @@ void RocksDBStore::RocksDBTransactionImpl::rmkeys_by_prefix(const string &prefix
        it->valid();
        it->next()) {
     string key = combine_strings(prefix, it->key());
-    keys.push_back(key);
-    bat->Delete(*(keys.rbegin()));
+    bat->Delete(key);
   }
 }
 
index e44977f3e46bbd7dc23cca4dfe4d4b6de6a52a14..2955bea82cbdb2b0dfc2092c9bd48f153afea521 100644 (file)
@@ -131,8 +131,6 @@ public:
   class RocksDBTransactionImpl : public KeyValueDB::TransactionImpl {
   public:
     rocksdb::WriteBatch *bat;
-    list<bufferlist> buffers;
-    list<string> keys;
     RocksDBStore *db;
 
     RocksDBTransactionImpl(RocksDBStore *_db);