From e0eb8fea876d6d49c9ac5d8abe7b29b5c66fc76b Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Fri, 12 Mar 2021 12:37:07 +0800 Subject: [PATCH 1/3] [btree (rust)] Show out-of-order keys --- src/pdata/btree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pdata/btree.rs b/src/pdata/btree.rs index 4351456..b7494f4 100644 --- a/src/pdata/btree.rs +++ b/src/pdata/btree.rs @@ -558,7 +558,7 @@ pub fn unpack_node( for k in &keys { if let Some(l) = last { if k <= l { - return Err(node_err(&path, "keys out of order")); + return Err(node_err(&path, &format!("keys out of order: {} <= {}", k, l))); } } From 8bfe7ee6f3fa89482a09d3c6ea933759f4d4b4a7 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Thu, 25 Mar 2021 15:06:52 +0800 Subject: [PATCH 2/3] [btree] Fix rebalancing checks --- persistent-data/data-structures/btree.tcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistent-data/data-structures/btree.tcc b/persistent-data/data-structures/btree.tcc index 059ebaa..27c9adc 100644 --- a/persistent-data/data-structures/btree.tcc +++ b/persistent-data/data-structures/btree.tcc @@ -338,7 +338,7 @@ namespace persistent_data { unsigned nr_right = rhs.get_nr_entries(); unsigned max_entries = get_max_entries(); - if (nr_left - count > max_entries || nr_right - count > max_entries) + if (nr_left - count > max_entries || nr_right + count > max_entries) throw runtime_error("too many entries"); if (count > 0) { From c496e8a4c85b3036455c47ff0600db18b07e3105 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Thu, 25 Mar 2021 16:42:36 +0800 Subject: [PATCH 3/3] [btree] Remove FIXMEs --- persistent-data/data-structures/btree-remove.tcc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/persistent-data/data-structures/btree-remove.tcc b/persistent-data/data-structures/btree-remove.tcc index 852d267..eeb3796 100644 --- a/persistent-data/data-structures/btree-remove.tcc +++ b/persistent-data/data-structures/btree-remove.tcc @@ -145,11 +145,11 @@ namespace persistent_data { { internal_node n = spine.get_node(); + // compact the path if there's only one child if (n.get_nr_entries() == 1) { block_address b = n.value_at(0); read_ref child = tm_.read_lock(b, validator_); - // FIXME: is it safe? ::memcpy(n.raw(), child.data(), read_ref::BLOCK_SIZE); tm_.get_sm()->dec(child.get_location()); @@ -341,7 +341,6 @@ namespace persistent_data { if (nr_left < nr_right) { int s = nr_left - target_left; - // FIXME: signed & unsigned comparison if (s < 0 && nr_center < static_cast(-s)) { // not enough in central node left.move_entries(center, -nr_center);