mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
crimson/os: use IsFullKey in staged::insert_size{,at}()
to fade out KeyT, so we can have more straightforward definitions. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
This commit is contained in:
parent
0e138d314b
commit
cb306cae7b
@ -871,7 +871,7 @@ class NodeLayoutT final : public InternalNodeImpl, public LeafNodeImpl {
|
||||
if (unlikely(is_keys_empty())) {
|
||||
assert(insert_pos.is_end());
|
||||
insert_stage = STAGE;
|
||||
insert_size = stage_t::template insert_size<KeyT::VIEW>(key, value);
|
||||
insert_size = stage_t::insert_size(key, value);
|
||||
} else {
|
||||
std::tie(insert_stage, insert_size) = stage_t::evaluate_insert(
|
||||
node_stage, key, value, cast_down<STAGE>(insert_pos), false);
|
||||
@ -893,7 +893,7 @@ class NodeLayoutT final : public InternalNodeImpl, public LeafNodeImpl {
|
||||
if (unlikely(is_keys_empty())) {
|
||||
assert(insert_pos.is_end());
|
||||
assert(is_level_tail());
|
||||
return {STAGE, stage_t::template insert_size<KeyT::HOBJ>(key, value)};
|
||||
return {STAGE, stage_t::insert_size(key, value)};
|
||||
} else {
|
||||
return stage_t::evaluate_insert(
|
||||
key, value, history, mstat, cast_down<STAGE>(insert_pos));
|
||||
|
@ -1133,27 +1133,27 @@ struct staged {
|
||||
}
|
||||
}
|
||||
|
||||
template <KeyT KT>
|
||||
static node_offset_t insert_size(const full_key_t<KT>& key,
|
||||
template <IsFullKey Key>
|
||||
static node_offset_t insert_size(const Key& key,
|
||||
const value_input_t& value) {
|
||||
if constexpr (IS_BOTTOM) {
|
||||
return iterator_t::estimate_insert(key, value);
|
||||
} else {
|
||||
return iterator_t::estimate_insert(key, value) +
|
||||
NXT_STAGE_T::iterator_t::header_size() +
|
||||
NXT_STAGE_T::template insert_size<KT>(key, value);
|
||||
NXT_STAGE_T::insert_size(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
template <KeyT KT>
|
||||
template <IsFullKey Key>
|
||||
static node_offset_t insert_size_at(match_stage_t stage,
|
||||
const full_key_t<KeyT::HOBJ>& key,
|
||||
const Key& key,
|
||||
const value_input_t& value) {
|
||||
if (stage == STAGE) {
|
||||
return insert_size<KT>(key, value);
|
||||
return insert_size(key, value);
|
||||
} else {
|
||||
assert(stage < STAGE);
|
||||
return NXT_STAGE_T::template insert_size_at<KT>(stage, key, value);
|
||||
return NXT_STAGE_T::template insert_size_at(stage, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1185,7 +1185,7 @@ struct staged {
|
||||
assert(match == std::strong_ordering::less);
|
||||
if (index == 0) {
|
||||
// already the first index, so insert at the current index
|
||||
return {STAGE, insert_size<KeyT::VIEW>(key, value)};
|
||||
return {STAGE, insert_size(key, value)};
|
||||
}
|
||||
--index;
|
||||
iter = iterator_t(container);
|
||||
@ -1199,7 +1199,7 @@ struct staged {
|
||||
if (match == std::strong_ordering::greater) {
|
||||
// key doesn't match both indexes, so insert at the current index
|
||||
++index;
|
||||
return {STAGE, insert_size<KeyT::VIEW>(key, value)};
|
||||
return {STAGE, insert_size(key, value)};
|
||||
} else {
|
||||
assert(match == std::strong_ordering::equal);
|
||||
if constexpr (IS_BOTTOM) {
|
||||
@ -1296,7 +1296,7 @@ struct staged {
|
||||
patch_insert_end(position, insert_stage);
|
||||
}
|
||||
|
||||
node_offset_t insert_size = insert_size_at<KeyT::HOBJ>(insert_stage, key, value);
|
||||
node_offset_t insert_size = insert_size_at(insert_stage, key, value);
|
||||
|
||||
return {insert_stage, insert_size};
|
||||
}
|
||||
@ -1349,7 +1349,7 @@ struct staged {
|
||||
if (iter.is_end()) {
|
||||
// insert at the higher stage due to split
|
||||
do_insert = true;
|
||||
_insert_size = insert_size<KT>(key, value);
|
||||
_insert_size = insert_size(key, value);
|
||||
stage = STAGE;
|
||||
}
|
||||
} else {
|
||||
@ -1361,7 +1361,7 @@ struct staged {
|
||||
if constexpr (!IS_BOTTOM) {
|
||||
position.nxt = position_t::nxt_t::begin();
|
||||
}
|
||||
assert(_insert_size == insert_size<KT>(key, value));
|
||||
assert(_insert_size == insert_size(key, value));
|
||||
if constexpr (IS_BOTTOM) {
|
||||
return iter.insert(
|
||||
mut, key, value, _insert_size, p_left_bound);
|
||||
@ -1394,11 +1394,11 @@ struct staged {
|
||||
if (position.is_end()) {
|
||||
position = position_t::begin();
|
||||
assert(stage == STAGE);
|
||||
assert(_insert_size == insert_size<KT>(key, value));
|
||||
assert(_insert_size == insert_size(key, value));
|
||||
} else if (position == position_t::begin()) {
|
||||
// when insert into a trimmed and empty left node
|
||||
stage = STAGE;
|
||||
_insert_size = insert_size<KT>(key, value);
|
||||
_insert_size = insert_size(key, value);
|
||||
} else {
|
||||
ceph_abort("impossible path");
|
||||
}
|
||||
|
@ -140,9 +140,9 @@ void validate_tree_config(const tree_conf_t& conf)
|
||||
|
||||
laddr_t i_value{0};
|
||||
auto insert_size_2 =
|
||||
_STAGE_T(InternalNode0)::template insert_size<KeyT::HOBJ>(key, i_value);
|
||||
_STAGE_T(InternalNode0)::insert_size(key, i_value);
|
||||
auto insert_size_0 =
|
||||
NXT_T(NXT_T(_STAGE_T(InternalNode0)))::template insert_size<KeyT::HOBJ>(key, i_value);
|
||||
NXT_T(NXT_T(_STAGE_T(InternalNode0)))::insert_size(key, i_value);
|
||||
unsigned internal_size_bound = sizeof(node_header_t) +
|
||||
(insert_size_2 + max_str_size) * 2 +
|
||||
(insert_size_2 - insert_size_0 + max_str_size);
|
||||
@ -151,9 +151,9 @@ void validate_tree_config(const tree_conf_t& conf)
|
||||
value_config_t l_value;
|
||||
l_value.payload_size = conf.max_value_payload_size;
|
||||
insert_size_2 =
|
||||
_STAGE_T(LeafNode0)::template insert_size<KeyT::HOBJ>(key, l_value);
|
||||
_STAGE_T(LeafNode0)::insert_size(key, l_value);
|
||||
insert_size_0 =
|
||||
NXT_T(NXT_T(_STAGE_T(LeafNode0)))::template insert_size<KeyT::HOBJ>(key, l_value);
|
||||
NXT_T(NXT_T(_STAGE_T(LeafNode0)))::insert_size(key, l_value);
|
||||
unsigned leaf_size_bound = sizeof(node_header_t) +
|
||||
(insert_size_2 + max_str_size) * 2 +
|
||||
(insert_size_2 - insert_size_0 + max_str_size);
|
||||
|
@ -139,24 +139,24 @@ TEST_F(a_basic_test_t, 1_basic_sizes)
|
||||
" LeafNode1: {} {} {}\n"
|
||||
" LeafNode2: {} {}\n"
|
||||
" LeafNode3: {}",
|
||||
_STAGE_T(InternalNode0)::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
NXT_T(_STAGE_T(InternalNode0))::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
NXT_T(NXT_T(_STAGE_T(InternalNode0)))::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
_STAGE_T(InternalNode1)::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
NXT_T(_STAGE_T(InternalNode1))::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
NXT_T(NXT_T(_STAGE_T(InternalNode1)))::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
_STAGE_T(InternalNode2)::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
NXT_T(_STAGE_T(InternalNode2))::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
_STAGE_T(InternalNode3)::template insert_size<KeyT::VIEW>(key_view, i_value),
|
||||
_STAGE_T(LeafNode0)::template insert_size<KeyT::HOBJ>(key, value),
|
||||
NXT_T(_STAGE_T(LeafNode0))::template insert_size<KeyT::HOBJ>(key, value),
|
||||
NXT_T(NXT_T(_STAGE_T(LeafNode0)))::template insert_size<KeyT::HOBJ>(key, value),
|
||||
_STAGE_T(LeafNode1)::template insert_size<KeyT::HOBJ>(key, value),
|
||||
NXT_T(_STAGE_T(LeafNode1))::template insert_size<KeyT::HOBJ>(key, value),
|
||||
NXT_T(NXT_T(_STAGE_T(LeafNode1)))::template insert_size<KeyT::HOBJ>(key, value),
|
||||
_STAGE_T(LeafNode2)::template insert_size<KeyT::HOBJ>(key, value),
|
||||
NXT_T(_STAGE_T(LeafNode2))::template insert_size<KeyT::HOBJ>(key, value),
|
||||
_STAGE_T(LeafNode3)::template insert_size<KeyT::HOBJ>(key, value)
|
||||
_STAGE_T(InternalNode0)::insert_size(key_view, i_value),
|
||||
NXT_T(_STAGE_T(InternalNode0))::insert_size(key_view, i_value),
|
||||
NXT_T(NXT_T(_STAGE_T(InternalNode0)))::insert_size(key_view, i_value),
|
||||
_STAGE_T(InternalNode1)::insert_size(key_view, i_value),
|
||||
NXT_T(_STAGE_T(InternalNode1))::insert_size(key_view, i_value),
|
||||
NXT_T(NXT_T(_STAGE_T(InternalNode1)))::insert_size(key_view, i_value),
|
||||
_STAGE_T(InternalNode2)::insert_size(key_view, i_value),
|
||||
NXT_T(_STAGE_T(InternalNode2))::insert_size(key_view, i_value),
|
||||
_STAGE_T(InternalNode3)::insert_size(key_view, i_value),
|
||||
_STAGE_T(LeafNode0)::insert_size(key, value),
|
||||
NXT_T(_STAGE_T(LeafNode0))::insert_size(key, value),
|
||||
NXT_T(NXT_T(_STAGE_T(LeafNode0)))::insert_size(key, value),
|
||||
_STAGE_T(LeafNode1)::insert_size(key, value),
|
||||
NXT_T(_STAGE_T(LeafNode1))::insert_size(key, value),
|
||||
NXT_T(NXT_T(_STAGE_T(LeafNode1)))::insert_size(key, value),
|
||||
_STAGE_T(LeafNode2)::insert_size(key, value),
|
||||
NXT_T(_STAGE_T(LeafNode2))::insert_size(key, value),
|
||||
_STAGE_T(LeafNode3)::insert_size(key, value)
|
||||
);
|
||||
std::free(p_mem);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user