From: Sage Weil Date: Thu, 18 May 2017 19:42:23 +0000 (-0400) Subject: kv/RocksDBStore: make rmkeys_by_prefix efficient X-Git-Tag: ses5-milestone6~8^2~19^2~72 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1e3f1fcc8271299cf4456a32e6977107dff308bb;p=ceph.git kv/RocksDBStore: make rmkeys_by_prefix efficient This matches what rm_range_keys does. Signed-off-by: Sage Weil --- diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index 7e1324371e6f..49d2334161ff 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -623,11 +623,18 @@ void RocksDBStore::RocksDBTransactionImpl::rm_single_key(const string &prefix, void RocksDBStore::RocksDBTransactionImpl::rmkeys_by_prefix(const string &prefix) { - KeyValueDB::Iterator it = db->get_iterator(prefix); - for (it->seek_to_first(); - it->valid(); - it->next()) { - bat.Delete(combine_strings(prefix, it->key())); + if (db->enable_rmrange) { + string endprefix = prefix; + endprefix.push_back('\x01'); + bat.DeleteRange(combine_strings(prefix, string()), + combine_strings(endprefix, string())); + } else { + KeyValueDB::Iterator it = db->get_iterator(prefix); + for (it->seek_to_first(); + it->valid(); + it->next()) { + bat.Delete(combine_strings(prefix, it->key())); + } } }