Merge pull request #167 from mingnus/main

btree minor fixes
This commit is contained in:
Joe Thornber 2021-03-25 09:31:21 +00:00 committed by GitHub
commit 89372c3fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 4 deletions

View File

@ -145,11 +145,11 @@ namespace persistent_data {
{
internal_node n = spine.get_node<block_traits>();
// 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<unsigned>(-s)) {
// not enough in central node
left.move_entries(center, -nr_center);

View File

@ -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) {

View File

@ -558,7 +558,7 @@ pub fn unpack_node<V: Unpack>(
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)));
}
}