mirror of
https://github.com/ceph/ceph
synced 2024-12-28 06:23:08 +00:00
Merge pull request #4928 from xiaoxichen/wip-cleanup-key
os/{LevelDB,Rocks}Store: don't keep key_list in transaction Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
commit
6df56f252b
@ -162,21 +162,19 @@ void LevelDBStore::LevelDBTransactionImpl::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(leveldb::Slice(*(keys.rbegin())));
|
||||
bat.Put(leveldb::Slice(*(keys.rbegin())),
|
||||
leveldb::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(leveldb::Slice(key));
|
||||
bat.Put(leveldb::Slice(key),
|
||||
leveldb::Slice(val.c_str(), val.length()));
|
||||
}
|
||||
|
||||
void LevelDBStore::LevelDBTransactionImpl::rmkey(const string &prefix,
|
||||
const string &k)
|
||||
{
|
||||
string key = combine_strings(prefix, k);
|
||||
keys.push_back(key);
|
||||
bat.Delete(leveldb::Slice(*(keys.rbegin())));
|
||||
bat.Delete(leveldb::Slice(key));
|
||||
}
|
||||
|
||||
void LevelDBStore::LevelDBTransactionImpl::rmkeys_by_prefix(const string &prefix)
|
||||
@ -186,8 +184,7 @@ void LevelDBStore::LevelDBTransactionImpl::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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,10 +177,7 @@ public:
|
||||
class LevelDBTransactionImpl : public KeyValueDB::TransactionImpl {
|
||||
public:
|
||||
leveldb::WriteBatch bat;
|
||||
list<bufferlist> buffers;
|
||||
list<string> keys;
|
||||
LevelDBStore *db;
|
||||
|
||||
LevelDBTransactionImpl(LevelDBStore *db) : db(db) {}
|
||||
void set(
|
||||
const string &prefix,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user