]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/onode-staged-tree: document create interfaces for tree_cursor_t
authorYingxin Cheng <yingxin.cheng@intel.com>
Thu, 4 Feb 2021 07:20:28 +0000 (15:20 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 4 Feb 2021 07:20:28 +0000 (15:20 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/onode_manager/staged-fltree/node.cc
src/crimson/os/seastore/onode_manager/staged-fltree/node.h

index 8585f461a889372467d8805d4d7442f4e2d0c229..18fb9739d7fb0274b5c17f3fe7c7d788f30a22d2 100644 (file)
@@ -758,7 +758,7 @@ LeafNode::get_next_cursor(context_t c, const search_position_t& pos)
   if (next_pos.is_end()) {
     if (unlikely(is_level_tail())) {
       return node_ertr::make_ready_future<Ref<tree_cursor_t>>(
-          new tree_cursor_t(this));
+          tree_cursor_t::create_end(this));
     } else {
       return get_next_cursor_from_parent(c);
     }
@@ -796,7 +796,7 @@ LeafNode::lookup_smallest(context_t)
   if (unlikely(impl->is_empty())) {
     assert(is_root());
     return node_ertr::make_ready_future<Ref<tree_cursor_t>>(
-        new tree_cursor_t(this));
+        tree_cursor_t::create_end(this));
   }
   auto pos = search_position_t::begin();
   key_view_t index_key;
@@ -811,7 +811,7 @@ LeafNode::lookup_largest(context_t)
   if (unlikely(impl->is_empty())) {
     assert(is_root());
     return node_ertr::make_ready_future<Ref<tree_cursor_t>>(
-        new tree_cursor_t(this));
+        tree_cursor_t::create_end(this));
   }
   search_position_t pos;
   const value_header_t* p_value_header = nullptr;
@@ -830,7 +830,7 @@ LeafNode::lower_bound_tracked(
   Ref<tree_cursor_t> cursor;
   if (result.position.is_end()) {
     assert(!result.p_value);
-    cursor = new tree_cursor_t(this);
+    cursor = tree_cursor_t::create_end(this);
   } else {
     cursor = get_or_track_cursor(result.position, index_key, result.p_value);
   }
@@ -955,7 +955,7 @@ Ref<tree_cursor_t> LeafNode::get_or_track_cursor(
   Ref<tree_cursor_t> p_cursor;
   auto found = tracked_cursors.find(position);
   if (found == tracked_cursors.end()) {
-    p_cursor = new tree_cursor_t(this, position, key, p_value_header);
+    p_cursor = tree_cursor_t::create(this, position, key, p_value_header);
   } else {
     p_cursor = found->second;
     assert(p_cursor->get_leaf_node() == this);
@@ -1000,7 +1000,7 @@ Ref<tree_cursor_t> LeafNode::track_insert(
   // track insert
   // TODO: getting key_view_t from stage::proceed_insert() and
   // stage::append_insert() has not supported yet
-  return new tree_cursor_t(this, insert_pos);
+  return tree_cursor_t::create(this, insert_pos);
 }
 
 void LeafNode::track_split(
index 9c9c02e103ca5a0d528adfd781bcf6a2c183a0d1..cf4a4508c262d89d8e5b24b3479dc4b77afd4166 100644 (file)
@@ -137,6 +137,19 @@ class tree_cursor_t final
   void update_cache(LeafNode&, const key_view_t&, const value_header_t*) const;
   void maybe_update_cache(value_magic_t magic) const;
 
+  static Ref<tree_cursor_t> create(Ref<LeafNode> node, const search_position_t& pos) {
+    return new tree_cursor_t(node, pos);
+  }
+
+  static Ref<tree_cursor_t> create(Ref<LeafNode> node, const search_position_t& pos,
+                                   const key_view_t& key, const value_header_t* p_header) {
+    return new tree_cursor_t(node, pos, key, p_header);
+  }
+
+  static Ref<tree_cursor_t> create_end(Ref<LeafNode> node) {
+    return new tree_cursor_t(node);
+  }
+
   /**
    * Reversed resource management (tree_cursor_t)
    *