]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kv: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 04:01:50 +0000 (12:01 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:23:38 +0000 (12:23 +0800)
* add "std::" prefix in headers
* add "using" declarations in .cc files.

so we don't rely on "using namespace std" in one or more included
headers.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h

index 40cf417248725fb62e1a82ddbaaa1d6dd532b977..4bd2495eedecc809b7967868d583858a7c966610 100644 (file)
@@ -757,7 +757,7 @@ void RocksDBStore::sharding_def_to_columns(const std::vector<ColumnFamily>& shar
        columns.push_back(sharding_def[i].name);
     } else {
       for (size_t j = 0; j < sharding_def[i].shard_cnt; j++) {
-       columns.push_back(sharding_def[i].name + "-" + to_string(j));
+       columns.push_back(sharding_def[i].name + "-" + std::to_string(j));
       }
     }
   }
@@ -781,7 +781,7 @@ int RocksDBStore::create_shards(const rocksdb::Options& opt,
       if (p.shard_cnt == 1)
        cf_name = p.name;
       else
-       cf_name = p.name + "-" + to_string(idx);
+       cf_name = p.name + "-" + std::to_string(idx);
       rocksdb::ColumnFamilyHandle *cf;
       status = db->CreateColumnFamily(cf_opt, cf_name, &cf);
       if (!status.ok()) {
@@ -1040,7 +1040,7 @@ int RocksDBStore::verify_sharding(const rocksdb::Options& opt,
       emplace_cf(column, 0, column.name, cf_opt);
     } else {
       for (size_t i = 0; i < column.shard_cnt; i++) {
-       std::string cf_name = column.name + "-" + to_string(i);
+       std::string cf_name = column.name + "-" + std::to_string(i);
        emplace_cf(column, i, cf_name, cf_opt);
       }
     }
@@ -2772,14 +2772,14 @@ public:
       if (iters[0]->Valid()) {
        if (iters[i]->Valid()) {
          if (keyless(iters[0], iters[i])) {
-           swap(iters[0], iters[i]);
+           std::swap(iters[0], iters[i]);
          }
        } else {
          //iters[i] empty
        }
       } else {
        if (iters[i]->Valid()) {
-         swap(iters[0], iters[i]);
+         std::swap(iters[0], iters[i]);
        }
       }
       //it might happen that cf was empty
@@ -3171,7 +3171,7 @@ int RocksDBStore::reshard_cleanup(const RocksDBStore::columns_t& current_columns
       new_sharding_columns.push_back(name);
     } else {
       for (size_t i = 0; i < handle.handles.size(); i++) {
-       new_sharding_columns.push_back(name + "-" + to_string(i));
+       new_sharding_columns.push_back(name + "-" + std::to_string(i));
       }
     }
   }
index 529b4ffa621ab26564b521b2ddef6e90d11569bb..41ec9520c5826e7e87415a510d320e5d346d35b7 100644 (file)
@@ -92,12 +92,12 @@ class RocksDBStore : public KeyValueDB {
    */
 public:
   struct ColumnFamily {
-    string name;      //< name of this individual column family
+    std::string name;      //< name of this individual column family
     size_t shard_cnt; //< count of shards
-    string options;   //< configure option string for this CF
+    std::string options;   //< configure option string for this CF
     uint32_t hash_l;  //< first character to take for hash calc.
     uint32_t hash_h;  //< last character to take for hash calc.
-    ColumnFamily(const string &name, size_t shard_cnt, const string &options,
+    ColumnFamily(const std::string &name, size_t shard_cnt, const std::string &options,
                 uint32_t hash_l, uint32_t hash_h)
       : name(name), shard_cnt(shard_cnt), options(options), hash_l(hash_l), hash_h(hash_h) {}
   };
@@ -142,7 +142,7 @@ private:
   static void sharding_def_to_columns(const std::vector<ColumnFamily>& sharding_def,
                                      std::vector<std::string>& columns);
   int create_shards(const rocksdb::Options& opt,
-                   const vector<ColumnFamily>& sharding_def);
+                   const std::vector<ColumnFamily>& sharding_def);
   int apply_sharding(const rocksdb::Options& opt,
                     const std::string& sharding_text);
   int verify_sharding(const rocksdb::Options& opt,
@@ -470,7 +470,7 @@ err:
     return static_cast<int64_t>(bbt_opts.block_cache->GetUsage());
   }
 
-  virtual int64_t get_cache_usage(string prefix) const override {
+  virtual int64_t get_cache_usage(std::string prefix) const override {
     auto it = cf_bbt_opts.find(prefix);
     if (it != cf_bbt_opts.end() && it->second.block_cache) {
       return static_cast<int64_t>(it->second.block_cache->GetUsage());
@@ -486,15 +486,15 @@ err:
 
   virtual std::shared_ptr<PriorityCache::PriCache>
       get_priority_cache() const override {
-    return dynamic_pointer_cast<PriorityCache::PriCache>(
+    return std::dynamic_pointer_cast<PriorityCache::PriCache>(
         bbt_opts.block_cache);
   }
 
   virtual std::shared_ptr<PriorityCache::PriCache>
-      get_priority_cache(string prefix) const override {
+      get_priority_cache(std::string prefix) const override {
     auto it = cf_bbt_opts.find(prefix);
     if (it != cf_bbt_opts.end()) {
-      return dynamic_pointer_cast<PriorityCache::PriCache>(
+      return std::dynamic_pointer_cast<PriorityCache::PriCache>(
           it->second.block_cache);
     }
     return nullptr;