]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/fixed_kv_node_layout: add support for node dependent values
authorSamuel Just <sjust@redhat.com>
Mon, 19 Oct 2020 20:10:32 +0000 (13:10 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 20 Oct 2020 19:27:12 +0000 (12:27 -0700)
node_[un]resolve_vals can be used by implementations to transform vals
during split and merge.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/common/fixed_kv_node_layout.h

index d284716da7267895a07fb37a232999bc3e9ca61d..4c7cc2e76a4373ba870b4da190880b1d21c63fad 100644 (file)
@@ -325,6 +325,8 @@ public:
   FixedKVNodeLayout(char *buf) :
     buf(buf) {}
 
+  virtual ~FixedKVNodeLayout() = default;
+
   const_iterator begin() const {
     return const_iterator(
       this,
@@ -638,6 +640,17 @@ private:
     return layout.template Pointer<3>(buf);
   }
 
+  /**
+   * node_resolve/unresolve_vals
+   *
+   * If the representation for values depends in some way on the
+   * node in which they are located, users may implement
+   * resolve/unresolve to enable copy_from_foreign to handle that
+   * transition.
+   */
+  virtual void node_resolve_vals(iterator from, iterator to) const {}
+  virtual void node_unresolve_vals(iterator from, iterator to) const {}
+
   /**
    * copy_from_foreign
    *
@@ -658,6 +671,8 @@ private:
     memcpy(
       tgt->get_key_ptr(), from_src->get_key_ptr(),
       to_src->get_key_ptr() - from_src->get_key_ptr());
+    from_src->node->node_resolve_vals(tgt, tgt + (to_src - from_src));
+    tgt->node->node_unresolve_vals(tgt, tgt + (to_src - from_src));
   }
 
   /**