}
eagain_future<std::pair<Ref<tree_cursor_t>, bool>> Node::insert(
- context_t c, const key_hobj_t& key, value_config_t vconf)
+ context_t c,
+ const key_hobj_t& key,
+ value_config_t vconf,
+ Ref<Node>&& this_ref)
{
return seastar::do_with(
- MatchHistory(), [this, c, &key, vconf](auto& history) {
+ MatchHistory(), [this, c, &key, vconf,
+ this_ref = std::move(this_ref)] (auto& history) mutable {
return lower_bound_tracked(c, key, history
- ).safe_then([c, &key, vconf, &history](auto result) {
+ ).safe_then([c, &key, vconf, &history,
+ this_ref = std::move(this_ref)] (auto result) mutable {
+ // the cursor in the result should already hold the root node upwards
+ this_ref.reset();
if (result.match() == MatchKindBS::EQ) {
return eagain_ertr::make_ready_future<std::pair<Ref<tree_cursor_t>, bool>>(
std::make_pair(result.p_cursor, false));
}
eagain_future<std::size_t> Node::erase(
- context_t c, const key_hobj_t& key)
+ context_t c,
+ const key_hobj_t& key,
+ Ref<Node>&& this_ref)
{
- return lower_bound(c, key).safe_then([c] (auto result) {
+ return lower_bound(c, key
+ ).safe_then([c, this_ref = std::move(this_ref)] (auto result) mutable {
+ // the cursor in the result should already hold the root node upwards
+ this_ref.reset();
if (result.match() != MatchKindBS::EQ) {
return eagain_ertr::make_ready_future<std::size_t>(0);
}
* - If false, the returned cursor points to the conflicting element in tree;
*/
eagain_future<std::pair<Ref<tree_cursor_t>, bool>> insert(
- context_t, const key_hobj_t&, value_config_t);
+ context_t, const key_hobj_t&, value_config_t, Ref<Node>&&);
/**
* erase
*
* Returns the number of erased key-value pairs (0 or 1).
*/
- eagain_future<std::size_t> erase(context_t, const key_hobj_t&);
+ eagain_future<std::size_t> erase(context_t, const key_hobj_t&, Ref<Node>&&);
/// Recursively collects the statistics of the sub-tree formed by this node
eagain_future<tree_stats_t> get_tree_stats(context_t);
[this, &t, vconf](auto& key) -> eagain_future<std::pair<Cursor, bool>> {
ceph_assert(key.is_valid());
return get_root(t).safe_then([this, &t, &key, vconf](auto root) {
- return root->insert(get_context(t), key, vconf);
+ return root->insert(get_context(t), key, vconf, std::move(root));
}).safe_then([this](auto ret) {
auto& [cursor, success] = ret;
return std::make_pair(Cursor(this, cursor), success);
full_key_t<KeyT::HOBJ>(obj),
[this, &t](auto& key) -> eagain_future<std::size_t> {
return get_root(t).safe_then([this, &t, &key](auto root) {
- return root->erase(get_context(t), key);
+ return root->erase(get_context(t), key, std::move(root));
});
}
);