]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: don't use real wholespace iterator for prefixed access 49963/head
authorIgor Fedotov <igor.fedotov@croit.io>
Wed, 1 Feb 2023 21:19:38 +0000 (00:19 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Wed, 1 Feb 2023 21:49:08 +0000 (00:49 +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>
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 bd716d2093f3038cae8d03e036cfee2f6e8421e4..b421098f78cc3c818750937040c7f61d81e013d1 100644 (file)
@@ -3011,7 +3011,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);
   }
 }