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)
Dependencies
- [2]
DASFQGORDebugging - [3]
73Z2UB3JCleanup + comments - [4]
OP6SVMODResetting history - [5]
ESUI5EUZMaking as_page() unsafe - [6]
LROAI3NBTwo iterators (convenience functions), along with tests to move cursors (put and del still destroy cursors though) - [7]
HN6Z5DU4Cleanup - [8]
TSMS6W4DFully commented implementation of Sized nodes + massive cleanup - [9]
UUUVNC4DDebugging/cleanup around cursors - [10]
OFINGD26implementing prev() on cursors (+ some cleanup) - [11]
KM3JAFGPAdding a test for next/prev - [12]
LSQ6V7M6Cleanup + docs - [13]
PXF3R6SVImproving test coverage for btree::cursor - [14]
XEU2QVLCDebugging after plugging this into Pijul
Change contents
- edit in sanakirja-core/src/btree/cursor.rs at line 166
self.first_rc_len = N_CURSORS; - edit in sanakirja-core/src/btree/cursor.rs at line 211
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(¤t.cursor) {let left = P::right_child(current.page.as_page(), ¤t.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,})if P::is_empty(¤t.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(), ¤t.cursor){} else {let (cur_entry, r) = if let Some((k, v, r)) = P::current(txn, current.page.as_page(), ¤t.cursor) {(Some((k, v)), r)} else {(None, P::right_child(current.page.as_page(), ¤t.cursor))}; - replacement in sanakirja-core/src/btree/cursor.rs at line 281
if r > 0 {if r != 0 { - replacement in sanakirja-core/src/btree/cursor.rs at line 286
})});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
unsafe {return Ok(Some((core::mem::transmute(k), core::mem::transmute(v))));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
/// 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./// 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
if P::is_empty(¤t.cursor) {if P::is_init(¤t.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(), ¤t.cursor); - replacement in sanakirja-core/src/btree/cursor.rs at line 329
})});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(), ¤t.cursor){let l = P::left_child(current.page.as_page(), ¤t.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
unsafe {return Ok(Some((core::mem::transmute(k), core::mem::transmute(v))));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);