crimson/onode-staged-tree: extend num_keys_t to support larger nodes

Also adjust the accroding layout related unit tests.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
This commit is contained in:
Yingxin Cheng 2021-06-02 23:44:07 +08:00
parent 7e24c625ed
commit f7e77c9bee
3 changed files with 12 additions and 15 deletions

View File

@ -123,9 +123,8 @@ node_range_t fields_free_range_before(
*/
template <typename SlotType>
struct _node_fields_013_t {
// TODO: decide by NODE_BLOCK_SIZE, sizeof(SlotType), sizeof(laddr_t)
// and the minimal size of variable_key.
using num_keys_t = uint8_t;
// should be enough to index all keys under 64 KiB node
using num_keys_t = uint16_t;
using key_t = typename SlotType::key_t;
using key_get_type = const key_t&;
using me_t = _node_fields_013_t<SlotType>;
@ -212,9 +211,8 @@ using node_fields_1_t = _node_fields_013_t<slot_1_t>;
* +-----------------------------------------------+
*/
struct node_fields_2_t {
// TODO: decide by NODE_BLOCK_SIZE, sizeof(node_off_t), sizeof(laddr_t)
// and the minimal size of variable_key.
using num_keys_t = uint8_t;
// should be enough to index all keys under 64 KiB node
using num_keys_t = uint16_t;
using key_t = ns_oid_view_t;
using key_get_type = key_t;
static constexpr field_type_t FIELD_TYPE = field_type_t::N2;
@ -306,8 +304,8 @@ template <unsigned MAX_NUM_KEYS>
struct _internal_fields_3_t {
using key_get_type = const snap_gen_t&;
using me_t = _internal_fields_3_t<MAX_NUM_KEYS>;
// TODO: decide by NODE_BLOCK_SIZE, sizeof(snap_gen_t), sizeof(laddr_t)
using num_keys_t = uint8_t;
// should be enough to index all keys under 64 KiB node
using num_keys_t = uint16_t;
static constexpr field_type_t FIELD_TYPE = field_type_t::N3;
static constexpr node_offset_t SIZE = sizeof(me_t);
static constexpr node_offset_t HEADER_SIZE =

View File

@ -159,9 +159,8 @@ class internal_sub_items_t::Appender {
*/
class leaf_sub_items_t {
public:
// TODO: decide by NODE_BLOCK_SIZE, sizeof(snap_gen_t),
// and the minimal size of value
using num_keys_t = uint8_t;
// should be enough to index all keys under 64 KiB node
using num_keys_t = uint16_t;
leaf_sub_items_t(const memory_range_t& range) {
assert(range.p_start < range.p_end);

View File

@ -1271,7 +1271,7 @@ TEST_F(c_dummy_test_t, 5_split_merge_internal_node)
keys.insert(make_ghobj(2, 2, 2, "ns2", "oid2" + padding_s, 2, 2));
keys.insert(make_ghobj(2, 2, 2, "ns2", "oid2" + padding_s, 3, 3));
keys.insert(make_ghobj(2, 2, 2, "ns2", "oid2" + padding_s, 4, 4));
auto padding_e = std::string(248, '_');
auto padding_e = std::string(247, '_');
keys.insert(make_ghobj(5, 5, 5, "ns4", "oid4" + padding_e, 2, 2));
keys.insert(make_ghobj(5, 5, 5, "ns4", "oid4" + padding_e, 3, 3));
keys.insert(make_ghobj(5, 5, 5, "ns4", "oid4" + padding_e, 4, 4));
@ -1386,7 +1386,7 @@ TEST_F(c_dummy_test_t, 5_split_merge_internal_node)
{
logger().info("\n---------------------------------------------"
"\nbefore internal node insert (3):\n");
auto padding = std::string(420, '_');
auto padding = std::string(419, '_');
auto keys = build_key_set({2, 5}, {2, 5}, {2, 5}, padding, true);
keys.erase(make_ghobj(4, 4, 4, "ns4", "oid4" + padding, 2, 2));
keys.erase(make_ghobj(4, 4, 4, "ns4", "oid4" + padding, 3, 3));
@ -1411,7 +1411,7 @@ TEST_F(c_dummy_test_t, 5_split_merge_internal_node)
keys.erase(make_ghobj(2, 2, 2, "ns2", "oid2" + padding, 2, 2));
keys.erase(make_ghobj(2, 2, 2, "ns2", "oid2" + padding, 3, 3));
keys.erase(make_ghobj(2, 2, 2, "ns2", "oid2" + padding, 4, 4));
auto padding_s = std::string(387, '_');
auto padding_s = std::string(386, '_');
keys.insert(make_ghobj(2, 2, 2, "ns2", "oid2" + padding_s, 2, 2));
keys.insert(make_ghobj(2, 2, 2, "ns2", "oid2" + padding_s, 3, 3));
keys.insert(make_ghobj(2, 2, 2, "ns2", "oid2" + padding_s, 4, 4));
@ -1459,7 +1459,7 @@ TEST_F(c_dummy_test_t, 5_split_merge_internal_node)
"\nbefore internal node insert (6):\n");
auto padding = std::string(328, '_');
auto keys = build_key_set({2, 5}, {2, 5}, {2, 5}, padding);
keys.insert(make_ghobj(5, 5, 5, "ns3", "oid3" + std::string(271, '_'), 3, 3));
keys.insert(make_ghobj(5, 5, 5, "ns3", "oid3" + std::string(270, '_'), 3, 3));
keys.insert(make_ghobj(9, 9, 9, "ns~last", "oid~last", 9, 9));
pool.build_tree(keys).unsafe_get0();