]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
neorados: Improve `cmp_omap` argument structure
authorAdam Emerson <aemerson@redhat.com>
Thu, 10 Aug 2023 03:59:34 +0000 (23:59 -0400)
committerAdam Emerson <aemerson@redhat.com>
Thu, 7 Dec 2023 21:23:08 +0000 (16:23 -0500)
A map from strings to value/op pairs is a bit much and a bit annoying
for what's essentially a list of assertions. Just use a vector.

Also put op in the middle so it matches `cmpxattr`.

Signed-off-by: Adam Emerson <aemerson@redhat.com>
src/include/neorados/RADOS.hpp
src/neorados/RADOS.cc

index 6268f0219f33f8771b73281abf64a26265667a15..60e57aa5fc902c2bbf2e04f8ce5116e071a5f3cf 100644 (file)
@@ -203,6 +203,12 @@ enum class cmp_op : std::uint8_t {
   lte = 6
 };
 
+struct cmp_assertion {
+  std::string attr;
+  cmp_op op;
+  ceph::buffer::list bl;
+};
+
 namespace alloc_hint {
 enum alloc_hint_t {
   sequential_write = 1,
@@ -309,9 +315,7 @@ public:
   void cmpxattr(std::string_view name, cmp_op op, std::uint64_t val);
   void assert_version(uint64_t ver);
   void assert_exists();
-  void cmp_omap(const boost::container::flat_map<std::string,
-                                                std::pair<ceph::buffer::list,
-                                                          cmp_op>>& assertions);
+  void cmp_omap(const std::vector<cmp_assertion>& assertions);
 
   void exec(std::string_view cls, std::string_view method,
            const ceph::buffer::list& inbl,
@@ -586,15 +590,11 @@ public:
     return std::move(*this);
   }
 
-  ReadOp& cmp_omap(
-    const boost::container::flat_map<
-      std::string, std::pair<ceph::buffer::list, cmp_op>>& assertions) & {
+  ReadOp& cmp_omap(const std::vector<cmp_assertion>& assertions) & {
     Op::cmp_omap(assertions);
     return *this;
   }
-  ReadOp&& cmp_omap(
-    const boost::container::flat_map<
-      std::string, std::pair<ceph::buffer::list, cmp_op>>& assertions) && {
+  ReadOp&& cmp_omap(const std::vector<cmp_assertion>& assertions) && {
     Op::cmp_omap(assertions);
     return std::move(*this);
   }
@@ -970,15 +970,11 @@ public:
     return std::move(*this);
   }
 
-  WriteOp& cmp_omap(
-    const boost::container::flat_map<
-      std::string, std::pair<ceph::buffer::list, cmp_op>>& assertions) & {
+  WriteOp& cmp_omap(const std::vector<cmp_assertion>& assertions) & {
     Op::cmp_omap(assertions);
     return *this;
   }
-  WriteOp&& cmp_omap(
-    const boost::container::flat_map<
-      std::string, std::pair<ceph::buffer::list, cmp_op>>& assertions) && {
+  WriteOp&& cmp_omap(const std::vector<cmp_assertion>& assertions) && {
     Op::cmp_omap(assertions);
     return std::move(*this);
   }
index 84cc200929f50a669a7b1e47eae1adc248d464dc..0c12b861c870cc522ffc44cf80be12ee519def5f 100644 (file)
@@ -444,13 +444,10 @@ void Op::assert_exists() {
     static_cast<ceph::real_time*>(nullptr),
     static_cast<bs::error_code*>(nullptr));
 }
-void Op::cmp_omap(const bc::flat_map<
-                 std::string, std::pair<cb::list,
-                 cmp_op>>& assertions) {
+void Op::cmp_omap(const std::vector<cmp_assertion>& assertions) {
   buffer::list bl;
   encode(uint32_t(assertions.size()), bl);
-  for (const auto& [key, assertion] : assertions) {
-    const auto& [value, op] = assertion;
+  for (const auto& [key, op, value] : assertions) {
     encode(key, bl);
     encode(value, bl);
     encode(int(op), bl);