MCPcopy Create free account
hub / github.com/ceph/ceph / erase

Method erase

src/include/cpp-btree/btree.h:1998–2031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1996
1997template <typename P>
1998auto btree<P>::erase(iterator iter) -> iterator {
1999 bool internal_delete = false;
2000 if (!iter.node->leaf()) {
2001 // Deletion of a value on an internal node. First, move the largest value
2002 // from our left child here, then delete that position (in remove_value()
2003 // below). We can get to the largest value from our left child by
2004 // decrementing iter.
2005 iterator internal_iter(iter);
2006 --iter;
2007 assert(iter.node->leaf());
2008 params_type::move(mutable_allocator(), iter.node->slot(iter.position),
2009 internal_iter.node->slot(internal_iter.position));
2010 internal_delete = true;
2011 }
2012
2013 // Delete the key from the leaf.
2014 iter.node->remove_value(iter.position, mutable_allocator());
2015 --size_;
2016
2017 // We want to return the next value after the one we just erased. If we
2018 // erased from an internal node (internal_delete == true), then the next
2019 // value is ++(++iter). If we erased from a leaf node (internal_delete ==
2020 // false) then the next value is ++iter. Note that ++iter may point to an
2021 // internal node and the value in the internal node may move to a leaf node
2022 // (iter.node) when rebalancing is performed at the leaf level.
2023
2024 iterator res = rebalance_after_delete(iter);
2025
2026 // If we erased from an internal node, advance the iterator.
2027 if (internal_delete) {
2028 ++res;
2029 }
2030 return res;
2031}
2032
2033template <typename P>
2034auto btree<P>::rebalance_after_delete(iterator iter) -> iterator {

Callers 8

mergeMethod · 0.45
removeMethod · 0.45
sub_finishMethod · 0.45
erase_ifFunction · 0.45
erase_ifFunction · 0.45
del_optMethod · 0.45
trim_client_rangesMethod · 0.45

Calls 7

endMethod · 0.95
assertFunction · 0.85
leafMethod · 0.80
remove_valueMethod · 0.80
clearFunction · 0.50
slotMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected