return child_ref->retire(c, std::move(child_ref)
).safe_then([c, this, child_pos, FNAME,
this_ref = std::move(this_ref)] () mutable {
- if ((impl->is_level_tail() && impl->is_keys_empty()) ||
- (!impl->is_level_tail() && impl->is_keys_one())) {
- // there is only one value left
+ if (impl->has_single_value()) {
// fast path without mutating the extent
DEBUGT("{} has one value left, erase ...", c.t, get_name());
#ifndef NDEBUG
[c, &pos, this_ref = std::move(this_ref), this, FNAME] () mutable {
#ifndef NDEBUG
assert(!impl->is_keys_empty());
- if (impl->is_keys_one()) {
+ if (impl->has_single_value()) {
assert(pos == search_position_t::begin());
}
#endif
- if (!is_root() && impl->is_keys_one()) {
+ if (!is_root() && impl->has_single_value()) {
// we need to keep the root as an empty leaf node
// fast path without mutating the extent
// track_erase
*/
virtual void validate_non_empty() const = 0;
virtual bool is_keys_empty() const = 0;
- // under the assumption that keys are not empty, check whether num_keys == 1
- virtual bool is_keys_one() const = 0;
+ // under the assumption that node is not empty
+ virtual bool has_single_value() const = 0;
virtual level_t level() const = 0;
virtual node_offset_t free_size() const = 0;
}
assert(!is_keys_empty());
}
+
bool is_keys_empty() const override { return extent.read().keys() == 0; }
- bool is_keys_one() const override {
- assert(!is_keys_empty());
- return STAGE_T::is_keys_one(extent.read());
+
+ bool has_single_value() const override {
+ validate_non_empty();
+ if constexpr (NODE_TYPE == node_type_t::INTERNAL) {
+ return ((is_level_tail() && is_keys_empty()) ||
+ (!is_level_tail() && STAGE_T::is_keys_one(extent.read())));
+ } else {
+ return STAGE_T::is_keys_one(extent.read());
+ }
}
level_t level() const override { return extent.read().level(); }
ceph_abort("impossible path"); }
bool is_keys_empty() const override {
ceph_abort("impossible path"); }
- bool is_keys_one() const override {
+ bool has_single_value() const override {
ceph_abort("impossible path"); }
node_offset_t free_size() const override {
ceph_abort("impossible path"); }