pijul nest
guest [sign in]

Updating the first_rc_len when moving a cursor (this is not used anywhere at the moment, and not part of the public API, but will be useful later)

pmeunier
Jul 30, 2021, 6:03 PM
26KI6CQSTGLQ4MGPLFQYPLDMH56M6VY6KQB5ONMQXUNV3ZX665TQC

Dependencies

  • [2] DASFQGOR Debugging
  • [3] 73Z2UB3J Cleanup + comments
  • [4] OP6SVMOD Resetting history
  • [5] ESUI5EUZ Making as_page() unsafe
  • [6] LROAI3NB Two iterators (convenience functions), along with tests to move cursors (put and del still destroy cursors though)
  • [7] HN6Z5DU4 Cleanup
  • [8] TSMS6W4D Fully commented implementation of Sized nodes + massive cleanup
  • [9] UUUVNC4D Debugging/cleanup around cursors
  • [10] OFINGD26 implementing prev() on cursors (+ some cleanup)
  • [11] KM3JAFGP Adding a test for next/prev
  • [12] LSQ6V7M6 Cleanup + docs
  • [13] PXF3R6SV Improving test coverage for btree::cursor
  • [14] XEU2QVLC Debugging after plugging this into Pijul

Change contents

  • edit in sanakirja-core/src/btree/cursor.rs at line 166
    [3.18947]
    [3.7764]
    self.first_rc_len = N_CURSORS;
  • edit in sanakirja-core/src/btree/cursor.rs at line 211
    [3.19559]
    [3.19559]
    self.first_rc_len = N_CURSORS;
  • replacement in sanakirja-core/src/btree/cursor.rs at line 265
    [3.20077][3.15636:15681](),[3.82][3.15636:15681](),[3.15681][3.20078:20162](),[3.8717][3.13357:13408](),[3.20162][3.13357:13408](),[3.84][3.13357:13408](),[3.13408][3.40970:41043](),[3.2446][3.12354:12481](),[3.41043][3.12354:12481](),[3.12354][3.12354:12481](),[3.12481][3.15682:15739](),[3.15739][3.12481:12511](),[3.12481][3.12481:12511](),[3.12577][3.12577:12600]()
    if P::is_init(&current.cursor) {
    let left = P::right_child(current.page.as_page(), &current.cursor);
    P::move_next(&mut current.cursor);
    // Visit the left child of the page (if any), i.e. push.
    if left != 0 {
    let page = txn.load_page(left)?;
    self.push(PageCursor {
    cursor: P::cursor_before(&page),
    page,
    })
    [3.20077]
    [3.12600]
    if P::is_empty(&current.cursor) {
    if self.len > 1 {
    if self.first_rc_len == self.len {
    self.first_rc_len = N_CURSORS
    }
    self.len -= 1
    } else {
    return Ok(None);
  • replacement in sanakirja-core/src/btree/cursor.rs at line 274
    [3.12618][3.20163:20264](),[3.8846][3.8172:8186](),[3.20264][3.8172:8186](),[3.8172][3.8172:8186]()
    } else if let Some((k, v, r)) = P::current(txn, current.page.as_page(), &current.cursor)
    {
    [3.12618]
    [3.13409]
    } else {
    let (cur_entry, r) = if let Some((k, v, r)) = P::current(txn, current.page.as_page(), &current.cursor) {
    (Some((k, v)), r)
    } else {
    (None, P::right_child(current.page.as_page(), &current.cursor))
    };
  • replacement in sanakirja-core/src/btree/cursor.rs at line 281
    [3.2522][3.12796:12823](),[3.13460][3.12796:12823](),[3.12796][3.12796:12823]()
    if r > 0 {
    [3.13460]
    [3.12823]
    if r != 0 {
  • replacement in sanakirja-core/src/btree/cursor.rs at line 286
    [3.13012][3.13012:13035]()
    })
    [3.12946]
    [3.646]
    });
    if self.first_rc_len >= N_CURSORS && txn.rc(r)? >= 2 {
    self.first_rc_len = self.len
    }
  • replacement in sanakirja-core/src/btree/cursor.rs at line 291
    [3.664][3.41044:41158]()
    unsafe {
    return Ok(Some((core::mem::transmute(k), core::mem::transmute(v))));
    [3.664]
    [3.41158]
    if let Some((k, v)) = cur_entry {
    unsafe {
    return Ok(Some((core::mem::transmute(k), core::mem::transmute(v))));
    }
  • edit in sanakirja-core/src/btree/cursor.rs at line 296
    [3.41176][3.20265:20332](),[3.13077][3.20265:20332](),[3.456][3.664:685](),[3.13146][3.664:685](),[3.20332][3.664:685](),[3.664][3.664:685](),[3.685][3.13147:13180]()
    } else if self.len > 1 {
    self.len -= 1
    } else {
    return Ok(None);
  • replacement in sanakirja-core/src/btree/cursor.rs at line 300
    [3.13211][2.10524:10700]()
    /// Move the cursor to the previous entry, and return the current
    /// entry. If the cursor is initially after all the entries, this
    /// moves it back by two steps.
    [3.13211]
    [3.41255]
    /// Move the cursor to the previous entry, and return the entry
    /// that was current before the move. If the cursor is initially
    /// after all the entries, this moves it back by two steps.
  • replacement in sanakirja-core/src/btree/cursor.rs at line 309
    [3.8421][3.15798:15844]()
    if P::is_empty(&current.cursor) {
    [3.20415]
    [3.20472]
    if P::is_init(&current.cursor) {
    if self.len > 1 {
    if self.first_rc_len == self.len {
    self.first_rc_len = N_CURSORS
    }
    self.len -= 1;
    let current = unsafe { &mut *self.stack[self.len - 1].as_mut_ptr() };
    P::move_prev(&mut current.cursor);
    } else {
    return Ok(None);
    }
    } else {
    let cur_entry = P::current(txn, current.page.as_page(), &current.cursor);
  • replacement in sanakirja-core/src/btree/cursor.rs at line 329
    [3.13815][3.13815:13838]()
    })
    [3.13750]
    [3.2691]
    });
    if self.first_rc_len >= N_CURSORS && txn.rc(left)? >= 2 {
    self.first_rc_len = self.len
    }
  • edit in sanakirja-core/src/btree/cursor.rs at line 335
    [2.10742][3.13461:13516](),[3.2716][3.13461:13516](),[3.2795][3.13838:13856](),[3.13516][3.13838:13856](),[3.13838][3.13838:13856](),[3.13856][3.20556:20657](),[3.9070][3.8523:8537](),[3.20657][3.8523:8537](),[3.8523][3.8523:8537](),[3.668][3.20658:20738](),[3.2876][3.14115:14235](),[3.9162][3.14115:14235](),[3.20738][3.14115:14235](),[3.14115][3.14115:14235](),[3.14235][3.15902:15958](),[3.15958][3.14235:14265](),[3.14235][3.14235:14265](),[3.14330][3.1266:1289](),[3.1266][3.1266:1289](),[3.1289][3.2877:2902]()
    P::move_prev(&mut current.cursor);
    }
    } else if let Some((k, v, _)) = P::current(txn, current.page.as_page(), &current.cursor)
    {
    let l = P::left_child(current.page.as_page(), &current.cursor);
    if l > 0 {
    let page = txn.load_page(l)?;
    self.push(PageCursor {
    cursor: P::cursor_after(&page),
    page,
    })
    } else {
  • replacement in sanakirja-core/src/btree/cursor.rs at line 337
    [3.70731][3.41381:41495]()
    unsafe {
    return Ok(Some((core::mem::transmute(k), core::mem::transmute(v))));
    [3.70731]
    [3.41495]
    if let Some((k, v, _)) = cur_entry {
    unsafe {
    return Ok(Some((core::mem::transmute(k), core::mem::transmute(v))));
    }
  • edit in sanakirja-core/src/btree/cursor.rs at line 342
    [3.41513][3.20739:20776](),[3.8579][3.20739:20776](),[3.700][3.20777:20894](),[3.20894][3.13573:13624](),[3.3068][3.13573:13624](),[3.3143][3.14441:14495](),[3.13624][3.14441:14495](),[3.14441][3.14441:14495]()
    } else if self.len > 1 {
    self.len -= 1;
    let current = unsafe { &mut *self.stack[self.len - 1].as_mut_ptr() };
    P::move_prev(&mut current.cursor);
    } else {
    return Ok(None);