]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kv/RocksDBStore: avoid redundant prefix lookup.
authorIgor Fedotov <igor.fedotov@croit.io>
Wed, 1 Feb 2023 20:53:41 +0000 (23:53 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Wed, 1 Feb 2023 21:48:57 +0000 (00:48 +0300)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h

index a3ecf3a5a1f7dc0806dccccf1c2cf7c53ee12ed5..bd716d2093f3038cae8d03e036cfee2f6e8421e4 100644 (file)
@@ -667,11 +667,10 @@ rocksdb::ColumnFamilyHandle *RocksDBStore::get_cf_handle(const std::string& pref
  * CF handle. In all other cases, we return a nullptr to indicate that the specified bounds cannot necessarily be mapped
  * to a single CF.
  */
-rocksdb::ColumnFamilyHandle *RocksDBStore::get_cf_handle(const std::string& prefix, const IteratorBounds& bounds) {
+rocksdb::ColumnFamilyHandle *RocksDBStore::check_cf_handle_bounds(const cf_handles_iterator& iter, const IteratorBounds& bounds) {
   if (!bounds.lower_bound || !bounds.upper_bound) {
     return nullptr;
   }
-  auto iter = cf_handles.find(prefix);
   ceph_assert(iter != cf_handles.end());
   ceph_assert(iter->second.handles.size() != 1);
   if (iter->second.hash_l != 0) {
@@ -2996,7 +2995,7 @@ KeyValueDB::Iterator RocksDBStore::get_iterator(const std::string& prefix, Itera
     if (cf_it->second.handles.size() == 1) {
       cf = cf_it->second.handles[0];
     } else if (cct->_conf->osd_rocksdb_iterator_bounds_enabled) {
-      cf = get_cf_handle(prefix, bounds);
+      cf = check_cf_handle_bounds(cf_it, bounds);
     }
     if (cf) {
       return std::make_shared<CFIteratorImpl>(
index 25a2045ffafe91836457ce5d0671892e76a2923c..629d6ef995e0ccb5d6ddeee2857278c495088c02 100644 (file)
@@ -122,6 +122,7 @@ private:
     std::vector<rocksdb::ColumnFamilyHandle *> handles;
   };
   std::unordered_map<std::string, prefix_shards> cf_handles;
+  typedef decltype(cf_handles)::iterator cf_handles_iterator;
   std::unordered_map<uint32_t, std::string> cf_ids_to_prefix;
   std::unordered_map<std::string, rocksdb::BlockBasedTableOptions> cf_bbt_opts;
   
@@ -132,7 +133,7 @@ private:
   rocksdb::ColumnFamilyHandle *get_key_cf(const prefix_shards& shards, const char* key, const size_t keylen);
   rocksdb::ColumnFamilyHandle *get_cf_handle(const std::string& prefix, const std::string& key);
   rocksdb::ColumnFamilyHandle *get_cf_handle(const std::string& prefix, const char* key, size_t keylen);
-  rocksdb::ColumnFamilyHandle *get_cf_handle(const std::string& prefix, const IteratorBounds& bounds);
+  rocksdb::ColumnFamilyHandle *check_cf_handle_bounds(const cf_handles_iterator& it, const IteratorBounds& bounds);
 
   int submit_common(rocksdb::WriteOptions& woptions, KeyValueDB::Transaction t);
   int install_cf_mergeop(const std::string &cf_name, rocksdb::ColumnFamilyOptions *cf_opt);