pijul nest
guest [sign in]

Adding the RootPage trait to access the raw bytes of a root page (needed in libpijul)

pmeunier
Jul 12, 2021, 9:12 PM
YDHYZA77LFQ7RSKTVOTOQRL7EUSXMWYOSJAE5YAH6HLHE64B75LQC

Dependencies

  • [2] SYURNHHL Adding the `put_mut` and `set_left_child` methods
  • [3] TJ2R4HAZ Accessing the root pages (unsafely, of course)
  • [4] YWFYZNLZ Cleanup + inter-process concurrency
  • [5] E4MD6T3L Proofreading and commenting of this crate (massive bug fixes included)
  • [6] SO25TWFL A few features for integrating it into Pijul
  • [7] OFINGD26 implementing prev() on cursors (+ some cleanup)
  • [8] OP6SVMOD Resetting history
  • [9] W2MIZD5B Single file databases + CRC for the root pages (checking the other pages makes everything very slow)

Change contents

  • replacement in sanakirja/src/lib.rs at line 107
    [4.2997][4.6577:6634]()
    pub use environment::{Commit, Env, MutTxn, RootDb, Txn};
    [4.2997]
    [2.2260]
    pub use environment::{Commit, Env, MutTxn, RootDb, Txn, RootPage};
  • edit in sanakirja/src/environment/muttxn.rs at line 619
    [4.4392]
    [4.20978]
    impl<E: Borrow<Env>, T> RootPage for MutTxn<E, T> {
    unsafe fn root_page(&self) -> &[u8; 4064] {
    let env = self.env.borrow();
    let maps = env.mmaps.lock();
    let ptr = maps[0].ptr.add(self.root * PAGE_SIZE + GLOBAL_HEADER_SIZE);
    &*(ptr as *const [u8; 4064])
    }
    }
  • edit in sanakirja/src/environment/mod.rs at line 562
    [4.106698]
    [4.106698]
    }
    /// Access the root page of a transaction.
    pub trait RootPage {
    /// The root page of this transaction.
    unsafe fn root_page(&self) -> &[u8; 4064];
  • edit in sanakirja/src/environment/mod.rs at line 570
    [4.106701]
    [4.31080]
    impl<E: Borrow<Env>> RootPage for Txn<E> {
    unsafe fn root_page(&self) -> &[u8; 4064] {
    let env = self.env.borrow();
    let maps = env.mmaps.lock();
    let ptr = maps[0].ptr.add(self.root * PAGE_SIZE + GLOBAL_HEADER_SIZE);
    &*(ptr as *const [u8; 4064])
    }
    }
  • edit in sanakirja/src/environment/mod.rs at line 630
    [3.671][3.671:961](),[3.961][4.18035:18041](),[4.18035][4.18035:18041]()
    /// The root page of this transaction.
    pub unsafe fn root_page(&mut self) -> &[u8; 4064] {
    let env = self.env.borrow();
    let maps = env.mmaps.lock();
    let ptr = maps[0].ptr.add(self.root * PAGE_SIZE + GLOBAL_HEADER_SIZE);
    &*(ptr as *const [u8; 4064])
    }