From: Adam C. Emerson Date: Fri, 29 Mar 2019 00:55:29 +0000 (-0400) Subject: kv: Update KeyValueDB.h to work without using namespace X-Git-Tag: v15.0.0~19^2~61 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bef8c0433dc56f2a2c68f9a2ccac60605327fca1;p=ceph.git kv: Update KeyValueDB.h to work without using namespace Signed-off-by: Adam C. Emerson --- diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h index 289e562f0d73..701fd68453cc 100644 --- a/src/kv/KeyValueDB.h +++ b/src/kv/KeyValueDB.h @@ -40,24 +40,24 @@ public: /// Set Keys void set( const std::string &prefix, ///< [in] Prefix for keys, or CF name - const std::map &to_set ///< [in] keys/values to set + const std::map &to_set ///< [in] keys/values to set ) { - std::map::const_iterator it; - for (it = to_set.begin(); it != to_set.end(); ++it) + for (auto it = to_set.cbegin(); it != to_set.cend(); ++it) set(prefix, it->first, it->second); } - /// Set Keys (via encoded bufferlist) + /// Set Keys (via encoded ceph::buffer::list) void set( const std::string &prefix, ///< [in] prefix, or CF name - bufferlist& to_set_bl ///< [in] encoded key/values to set + ceph::buffer::list& to_set_bl ///< [in] encoded key/values to set ) { + using ceph::decode; auto p = std::cbegin(to_set_bl); uint32_t num; decode(num, p); while (num--) { string key; - bufferlist value; + ceph::buffer::list value; decode(key, p); decode(value, p); set(prefix, key, value); @@ -68,21 +68,22 @@ public: virtual void set( const std::string &prefix, ///< [in] Prefix or CF for the key const std::string &k, ///< [in] Key to set - const bufferlist &bl ///< [in] Value to set + const ceph::buffer::list &bl ///< [in] Value to set ) = 0; virtual void set( const std::string &prefix, const char *k, size_t keylen, - const bufferlist& bl) { + const ceph::buffer::list& bl) { set(prefix, string(k, keylen), bl); } - /// Removes Keys (via encoded bufferlist) + /// Removes Keys (via encoded ceph::buffer::list) void rmkeys( const std::string &prefix, ///< [in] Prefix or CF to search for - bufferlist &keys_bl ///< [in] Keys to remove + ceph::buffer::list &keys_bl ///< [in] Keys to remove ) { + using ceph::decode; auto p = std::cbegin(keys_bl); uint32_t num; decode(num, p); @@ -98,8 +99,7 @@ public: const std::string &prefix, ///< [in] Prefix/CF to search for const std::set &keys ///< [in] Keys to remove ) { - std::set::const_iterator it; - for (it = keys.begin(); it != keys.end(); ++it) + for (auto it = keys.cbegin(); it != keys.cend(); ++it) rmkey(prefix, *it); } @@ -141,7 +141,7 @@ public: virtual void merge( const std::string &prefix, ///< [in] Prefix/CF ==> MUST match some established merge operator const std::string &key, ///< [in] Key to be merged - const bufferlist &value ///< [in] value to be merged into key + const ceph::buffer::list &value ///< [in] value to be merged into key ) { ceph_abort_msg("Not implemented"); } virtual ~TransactionImpl() {} @@ -151,18 +151,18 @@ public: /// create a new instance static KeyValueDB *create(CephContext *cct, const std::string& type, const std::string& dir, - map options = {}, + std::map options = {}, void *p = NULL); /// test whether we can successfully initialize; may have side effects (e.g., create) static int test_init(const std::string& type, const std::string& dir); virtual int init(string option_str="") = 0; - virtual int open(std::ostream &out, const vector& cfs = {}) = 0; - // vector cfs contains column families to be created when db is created. + virtual int open(std::ostream &out, const std::vector& cfs = {}) = 0; + // std::vector cfs contains column families to be created when db is created. virtual int create_and_open(std::ostream &out, - const vector& cfs = {}) = 0; + const std::vector& cfs = {}) = 0; - virtual int open_read_only(ostream &out, const vector& cfs = {}) { + virtual int open_read_only(std::ostream &out, const std::vector& cfs = {}) { return -ENOTSUP; } @@ -181,26 +181,26 @@ public: virtual int get( const std::string &prefix, ///< [in] Prefix/CF for key const std::set &key, ///< [in] Key to retrieve - std::map *out ///< [out] Key value retrieved + std::map *out ///< [out] Key value retrieved ) = 0; virtual int get(const std::string &prefix, ///< [in] prefix or CF name const std::string &key, ///< [in] key - bufferlist *value) { ///< [out] value + ceph::buffer::list *value) { ///< [out] value std::set ks; ks.insert(key); - std::map om; + std::map om; int r = get(prefix, ks, &om); if (om.find(key) != om.end()) { *value = std::move(om[key]); } else { - *value = bufferlist(); + *value = ceph::buffer::list(); r = -ENOENT; } return r; } virtual int get(const string &prefix, const char *key, size_t keylen, - bufferlist *value) { + ceph::buffer::list *value) { return get(prefix, string(key, keylen), value); } @@ -215,7 +215,7 @@ public: virtual bool valid() = 0; virtual int next() = 0; virtual std::string key() = 0; - virtual bufferlist value() = 0; + virtual ceph::buffer::list value() = 0; virtual int status() = 0; virtual ~SimplestIteratorImpl() {} }; @@ -226,12 +226,12 @@ public: virtual int seek_to_last() = 0; virtual int prev() = 0; virtual std::pair raw_key() = 0; - virtual bufferptr value_as_ptr() { - bufferlist bl = value(); + virtual ceph::buffer::ptr value_as_ptr() { + ceph::buffer::list bl = value(); if (bl.length() == 1) { return *bl.buffers().begin(); } else if (bl.length() == 0) { - return bufferptr(); + return ceph::buffer::ptr(); } else { ceph_abort(); } @@ -254,13 +254,13 @@ public: virtual std::string key() = 0; virtual std::pair raw_key() = 0; virtual bool raw_key_is_prefixed(const std::string &prefix) = 0; - virtual bufferlist value() = 0; - virtual bufferptr value_as_ptr() { - bufferlist bl = value(); + virtual ceph::buffer::list value() = 0; + virtual ceph::buffer::ptr value_as_ptr() { + ceph::buffer::list bl = value(); if (bl.length()) { return *bl.buffers().begin(); } else { - return bufferptr(); + return ceph::buffer::ptr(); } } virtual int status() = 0; @@ -313,10 +313,10 @@ private: std::pair raw_key() override { return generic_iter->raw_key(); } - bufferlist value() override { + ceph::buffer::list value() override { return generic_iter->value(); } - bufferptr value_as_ptr() override { + ceph::buffer::ptr value_as_ptr() override { return generic_iter->value_as_ptr(); } int status() override { @@ -408,7 +408,7 @@ public: return -EOPNOTSUPP; } - virtual void get_statistics(Formatter *f) { + virtual void get_statistics(ceph::Formatter *f) { return; }