pijul nest
guest [sign in]

Adding the `put_mut` and `set_left_child` methods

[?]
Mar 9, 2021, 1:35 PM
SYURNHHL3P22ZAERTML4YW3DYLATHY5ALZH4GL5NF3LENDSKL2NQC

Dependencies

  • [2] DASFQGOR Debugging
  • [3] T7QB6QEP Adding debug.rs
  • [4] W2MIZD5B Single file databases + CRC for the root pages (checking the other pages makes everything very slow)
  • [5] MSRWB47Y Deletions at immutable leaves weren't really deleting anything
  • [6] 6DMPXOAT More debugging
  • [7] SO25TWFL A few features for integrating it into Pijul
  • [8] E4MD6T3L Proofreading and commenting of this crate (massive bug fixes included)
  • [9] WS4ZQM4R Debugging, tests, etc.
  • [10] FZBLNBGN Diagnostic tools (add_refs, check_free) + cleanup
  • [11] OFINGD26 implementing prev() on cursors (+ some cleanup)
  • [12] QBDBAQXY Better graphviz debugging (include values)
  • [13] UAQX27N4 Tests
  • [14] LSQ6V7M6 Cleanup + docs
  • [15] NXMFNPZ7 Comments + debugging drop
  • [16] ONES3V46 reference counting works for put
  • [17] OP6SVMOD Resetting history
  • [18] Q7DRIBBR Debugging replace (which cannot be del+put)
  • [19] X3QVVQIS More debugging (del seems to work now)
  • [*] H3FVSQIQ Unsized pages
  • [*] 52X5P7ND Cleaning up the unsized part
  • [*] TSMS6W4D Fully commented implementation of Sized nodes + massive cleanup
  • [*] 73Z2UB3J Cleanup + comments

Change contents

  • edit in sanakirja-core/src/btree/page_unsized.rs at line 341
    [21.4585]
    [22.9840]
    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
    [3.11472]
    [23.10883]
    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
    [3.14949][3.2983:3039](),[3.2983][3.2983:3039]()
    let (k, _) = curs.set_last(&txn).unwrap().unwrap();
    [3.14949]
    [3.3039]
    curs.set_last(&txn).unwrap();
    let (k, _) = curs.prev(&txn).unwrap().unwrap();
  • replacement in sanakirja/src/tests.rs at line 391
    [3.15017][3.5592:5650](),[3.5592][3.5592:5650]()
    let (&nn, _) = curs.set_last(&txn).unwrap().unwrap();
    [3.15017]
    [3.1518]
    curs.set_last(&txn).unwrap();
    let (&nn, _) = curs.prev(&txn).unwrap().unwrap();
  • replacement in sanakirja/src/tests.rs at line 413
    [3.507][3.507:560]()
    assert!(curs.set_last(&txn).unwrap().is_none());
    [3.507]
    [3.5674]
    curs.set_last(&txn).unwrap();
    assert!(curs.next(&txn).unwrap().is_none());
  • replacement in sanakirja/src/tests.rs at line 440
    [3.382][3.382:443](),[3.443][3.103:122]()
    let mut db: Db<u64, u64> = create_db(&mut txn).unwrap();
    let n = 20u64;
    [3.382]
    [3.122]
    let mut db: Db<u64, A> = create_db(&mut txn).unwrap();
    let n = 200u64;
  • replacement in sanakirja/src/tests.rs at line 445
    [3.10883][3.10883:10932]()
    put(&mut txn, &mut db, &i, &i).unwrap();
    [3.10883]
    [3.10932]
    let a = A([i; 100]);
    put(&mut txn, &mut db, &i, &a).unwrap();
  • replacement in sanakirja/src/tests.rs at line 451
    [3.10997][3.3723:3771]()
    let _db2 = fork_db(&mut txn, &db).unwrap();
    [3.10997]
    [3.11044]
    let db2 = fork_db(&mut txn, &db).unwrap();
  • edit in sanakirja/src/tests.rs at line 453
    [3.11092]
    [3.11092]
    debug(&txn, &[&db, &db2], "debug0", true);
  • replacement in sanakirja/src/lib.rs at line 108
    [3.6634][3.6634:6717]()
    pub use sanakirja_core::{btree, direct_repr, LoadPage, Storable, UnsizedStorable};
    [3.6634]
    [3.312]
    pub use sanakirja_core::{btree, direct_repr, LoadPage, AllocPage, Storable, UnsizedStorable, MutPage, CowPage, Page};
  • edit in sanakirja/src/environment/muttxn.rs at line 413
    [3.17561]
    [3.17561]
    debug!("free_for_all {:?}", i);
  • replacement in sanakirja/src/environment/muttxn.rs at line 492
    [3.89127][2.20030:20082]()
    debug!("incr rc {:?} {:?}", off, rc+1);
    [3.89127]
    [3.19176]
    debug!("incr rc 0x{:x} {:?}", off, rc+1);
  • edit in sanakirja/src/environment/mod.rs at line 589
    [3.18025]
    [3.18025]
    }
    }
    }
    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
    [3.2481][2.20722:20773]()
    debug!("CURSOR: {:?} {:?}", p.offset, cursor);