]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: don't use real wholespace iterator for prefixed access 50495/head
authorIgor Fedotov <igor.fedotov@croit.io>
Wed, 1 Feb 2023 21:19:38 +0000 (00:19 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Mon, 13 Mar 2023 11:20:38 +0000 (14:20 +0300)
We can bound to default CF when here are no matching CF for a specified prefix.
No need to use real wholespace iterator running over every CF. Hence we
might benefit from not iterating over large but useless CFs, e.g. OMAP related ones.

Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
(cherry picked from commit 46c0a61f578c02e8a5cf4e29415989ae6ec4681c)

src/kv/KeyValueDB.h
src/kv/RocksDBStore.cc

index 98bf0c07c43f468048bfa701467bde0bbc842c78..9cfb4482706c967190e9539afc4369b30c184dfe 100644 (file)
@@ -322,6 +322,12 @@ private:
       return generic_iter->status();
     }
   };
+protected:
+  Iterator make_iterator(const std::string &prefix, WholeSpaceIterator w_iter) {
+    return std::make_shared<PrefixIteratorImpl>(
+      prefix,
+      w_iter);
+  }
 public:
   typedef uint32_t IteratorOpts;
   static const uint32_t ITERATOR_NOCACHE = 1;
@@ -333,8 +339,7 @@ public:
 
   virtual WholeSpaceIterator get_wholespace_iterator(IteratorOpts opts = 0) = 0;
   virtual Iterator get_iterator(const std::string &prefix, IteratorOpts opts = 0, IteratorBounds bounds = IteratorBounds()) {
-    return std::make_shared<PrefixIteratorImpl>(
-      prefix,
+    return make_iterator(prefix,
       get_wholespace_iterator(opts));
   }
 
index 2176b503029e5558162441633a3aed3cf1e4a64b..2492235e639169e640333e53d47452beff8d2a2b 100644 (file)
@@ -3002,7 +3002,13 @@ KeyValueDB::Iterator RocksDBStore::get_iterator(const std::string& prefix, Itera
         std::move(bounds));
     }
   } else {
-    return KeyValueDB::get_iterator(prefix, opts);
+    // use wholespace engine if no cfs are configured
+    // or use default cf otherwise as there is no
+    // matching cf for the specified prefix.
+    auto w_it = cf_handles.size() == 0 || prefix.empty() ?
+      get_wholespace_iterator(opts) :
+      get_default_cf_iterator();
+    return KeyValueDB::make_iterator(prefix, w_it);
   }
 }