Adding the `put_mut` and `set_left_child` methods
[?]
Mar 9, 2021, 1:35 PM
SYURNHHL3P22ZAERTML4YW3DYLATHY5ALZH4GL5NF3LENDSKL2NQCDependencies
- [2]
DASFQGORDebugging - [3]
T7QB6QEPAdding debug.rs - [4]
W2MIZD5BSingle file databases + CRC for the root pages (checking the other pages makes everything very slow) - [5]
MSRWB47YDeletions at immutable leaves weren't really deleting anything - [6]
6DMPXOATMore debugging - [7]
SO25TWFLA few features for integrating it into Pijul - [8]
E4MD6T3LProofreading and commenting of this crate (massive bug fixes included) - [9]
WS4ZQM4RDebugging, tests, etc. - [10]
FZBLNBGNDiagnostic tools (add_refs, check_free) + cleanup - [11]
OFINGD26implementing prev() on cursors (+ some cleanup) - [12]
QBDBAQXYBetter graphviz debugging (include values) - [13]
UAQX27N4Tests - [14]
LSQ6V7M6Cleanup + docs - [15]
NXMFNPZ7Comments + debugging drop - [16]
ONES3V46reference counting works for put - [17]
OP6SVMODResetting history - [18]
Q7DRIBBRDebugging replace (which cannot be del+put) - [19]
X3QVVQISMore debugging (del seems to work now) - [*]
H3FVSQIQUnsized pages - [*]
52X5P7NDCleaning up the unsized part - [*]
TSMS6W4DFully commented implementation of Sized nodes + massive cleanup - [*]
73Z2UB3JCleanup + comments
Change contents
- edit in sanakirja-core/src/btree/page_unsized.rs at line 341
unsafe fn put_mut(page: &mut MutPage,c: &Self::Cursor,k0: &K,v0: &V,r: u64,) {let mut n = c.cur;if r == 0 {Leaf::alloc_write(page, k0, v0, 0, r, &mut n);} else {Internal::alloc_write(page, k0, v0, 0, r, &mut n);}}unsafe fn set_left_child(page: &mut MutPage,c: &Self::Cursor,l: u64) {let off = (page.0.data.add(HDR) as *mut u64).offset(c.cur - 1);*off = (l | (u64::from_le(*off) & 0xfff)).to_le();} - edit in sanakirja-core/src/btree/page.rs at line 343
unsafe fn put_mut(page: &mut MutPage,c: &Self::Cursor,k0: &K,v0: &V,r: u64,) {use super::page_unsized::AllocWrite;let mut n = c.cur;if r == 0 {Leaf::alloc_write(page, k0, v0, 0, r, &mut n);} else {Internal::alloc_write(page, k0, v0, 0, r, &mut n);}}unsafe fn set_left_child(page: &mut MutPage,c: &Self::Cursor,l: u64) {let off = (page.0.data.add(HDR) as *mut u64).offset(c.cur - 1);*off = (l | (u64::from_le(*off) & 0xfff)).to_le();} - edit in sanakirja-core/src/btree/mod.rs at line 171[3.48501][24.11013]
/// Add an entry to `page`, at position `c`. Does not check/// whether there is enough space to do so. This method is mostly/// useful for cloning pages.#[allow(unused_variables)]unsafe fn put_mut(page: &mut MutPage,c: &Self::Cursor,k0: &K,v0: &V,r: u64,) {unimplemented!()}#[allow(unused_variables)]unsafe fn set_left_child(page: &mut MutPage,c: &Self::Cursor,l: u64) {unimplemented!()} - replacement in sanakirja/src/tests.rs at line 341
let (k, _) = curs.set_last(&txn).unwrap().unwrap();curs.set_last(&txn).unwrap();let (k, _) = curs.prev(&txn).unwrap().unwrap(); - replacement in sanakirja/src/tests.rs at line 391
let (&nn, _) = curs.set_last(&txn).unwrap().unwrap();curs.set_last(&txn).unwrap();let (&nn, _) = curs.prev(&txn).unwrap().unwrap(); - replacement in sanakirja/src/tests.rs at line 413
assert!(curs.set_last(&txn).unwrap().is_none());curs.set_last(&txn).unwrap();assert!(curs.next(&txn).unwrap().is_none()); - replacement in sanakirja/src/tests.rs at line 440
let mut db: Db<u64, u64> = create_db(&mut txn).unwrap();let n = 20u64;let mut db: Db<u64, A> = create_db(&mut txn).unwrap();let n = 200u64; - replacement in sanakirja/src/tests.rs at line 445
put(&mut txn, &mut db, &i, &i).unwrap();let a = A([i; 100]);put(&mut txn, &mut db, &i, &a).unwrap(); - replacement in sanakirja/src/tests.rs at line 451
let _db2 = fork_db(&mut txn, &db).unwrap();let db2 = fork_db(&mut txn, &db).unwrap(); - edit in sanakirja/src/tests.rs at line 453
debug(&txn, &[&db, &db2], "debug0", true); - replacement in sanakirja/src/lib.rs at line 108
pub use sanakirja_core::{btree, direct_repr, LoadPage, Storable, UnsizedStorable};pub use sanakirja_core::{btree, direct_repr, LoadPage, AllocPage, Storable, UnsizedStorable, MutPage, CowPage, Page}; - edit in sanakirja/src/environment/muttxn.rs at line 413
debug!("free_for_all {:?}", i); - replacement in sanakirja/src/environment/muttxn.rs at line 492
debug!("incr rc {:?} {:?}", off, rc+1);debug!("incr rc 0x{:x} {:?}", off, rc+1); - edit in sanakirja/src/environment/mod.rs at line 589
}}}impl<E: Borrow<Env>> Txn<E> {/// A "raw" version of the `root_db` method, useful to store/// things other than databases.pub fn root(&self, n: usize) -> u64 {assert!(n <= (4096 - GLOBAL_HEADER_SIZE) / 8);unsafe {let env = self.env.borrow();let maps = env.mmaps.lock();*(maps[0].ptr.add(self.root * PAGE_SIZE + GLOBAL_HEADER_SIZE + 8 * n)as *mut u64) - edit in sanakirja/src/debug.rs at line 100
debug!("CURSOR: {:?} {:?}", p.offset, cursor);