]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
kv/RocksDBStore: make rmkeys_by_prefix efficient
authorSage Weil <sage@redhat.com>
Thu, 18 May 2017 19:42:23 +0000 (15:42 -0400)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:02:44 +0000 (13:02 -0400)
This matches what rm_range_keys does.

Signed-off-by: Sage Weil <sage@redhat.com>
src/kv/RocksDBStore.cc

index 7e1324371e6fe5d0407129b077a5646acd6c44d2..49d2334161ff5851fe493278f7f4a9ffc3875585 100644 (file)
@@ -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()));
+    }
   }
 }