From: Igor Fedotov Date: Wed, 28 Aug 2024 12:13:22 +0000 (+0300) Subject: kv: add a pair of informative getters to KeyValueDB::TransactionImpl X-Git-Tag: v20.0.0~712^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1f99b55488b5135b6348584b812758661c05ab72;p=ceph.git kv: add a pair of informative getters to KeyValueDB::TransactionImpl Signed-off-by: Igor Fedotov --- diff --git a/src/kv/KeyValueDB.h b/src/kv/KeyValueDB.h index 9cfb4482706..858742d511e 100644 --- a/src/kv/KeyValueDB.h +++ b/src/kv/KeyValueDB.h @@ -24,6 +24,12 @@ class KeyValueDB { public: class TransactionImpl { public: + // amount of ops included + virtual size_t get_count() const = 0; + + // total encoded data size + virtual size_t get_size_bytes() const = 0; + /// Set Keys void set( const std::string &prefix, ///< [in] Prefix for keys, or CF name diff --git a/src/kv/RocksDBStore.h b/src/kv/RocksDBStore.h index a8468a25d4d..477b209854c 100644 --- a/src/kv/RocksDBStore.h +++ b/src/kv/RocksDBStore.h @@ -299,6 +299,12 @@ public: const std::string &k, const ceph::bufferlist &to_set_bl); public: + size_t get_count() const override { + return bat.Count(); + } + size_t get_size_bytes() const override { + return bat.GetDataSize(); + } void set( const std::string &prefix, const std::string &k, diff --git a/src/test/ObjectMap/KeyValueDBMemory.h b/src/test/ObjectMap/KeyValueDBMemory.h index de84ede9049..8f6381dd52b 100644 --- a/src/test/ObjectMap/KeyValueDBMemory.h +++ b/src/test/ObjectMap/KeyValueDBMemory.h @@ -69,7 +69,14 @@ public: explicit TransactionImpl_(KeyValueDBMemory *db) : db(db) {} - + // dummy implementation + size_t get_count() const override { + return 0; + } + // dummy implementation + size_t get_size_bytes() const override { + return 0; + } struct SetOp : public Context { KeyValueDBMemory *db; std::pair key;