5LSYTRQ6IOVUW26VJW5SWGFEIB7T2N4PVEB6VMNMR5ZHQ75MFOQAC
FZBLNBGNQPNTLBNPNZ2C6DJ5323MZQ2PH54F6ZEKPFCK7TGJFGWAC
6UVFCERMGSGNRWCVC3GWO5HWV6MSWE433DXBJVC7KRPP6LLJLCSQC
AFKBHYVE25QMIU2WZATEGWG2EXSBQZ44DVDPACKNS3M4QGBF4ONAC
UAQX27N4PI4LHEW6LSHJETIE5MV7JTEMPLTJFYUBMYVPC43H7VOAC
G4JEQLLX6Q7VVFVAEJZAVQXX33MQ36CSCYSMJ5NQM5VZ76DXKU6QC
AOX2XQISHGWNNAFBYRN44Q6AWG7H5DPBK5YMFHK42HQNZ2TMHEJQC
E4MD6T3LNOYWVFTFFWCUKRNS4M2XVSKRLDWPYHMZHGDNO2T5JREQC
W2MIZD5BNL7A5HVFWTESF57QU7T6QMEF4RBSLFQXMEEU3XD2NU2QC
OP6SVMOD2GTQ7VNJ4E5KYFG4MIYA7HBMXJTADALMZH4PY7OQRMZQC
OFINGD26ZWCRDVVDI2ZIBLMHXKEMJA6MRNLANJYUHQPIJLPA7J2AC
OTWDDJE7TTE73D6BGF4ZN6BH2NFUFLPME2VJ3CPALH463UGWLEIQC
PXF3R6SVXJXN2NMLMWNY5OFV5QYVE2VZTLGIZDZVK5ZVLFTVSSWQC
T7QB6QEPWBXAU3RL7LE4GRDWWNQ65ZU2YNNTWBYLORJOABAQFEZQC
OHUZ73MKWD7SSB4DKKA532DEQKXQDS6PZ6HJ3EC2DLVJSLQH3NLAC
let mut db = create_db_::<MutTxn<&Env, ()>, u64, u64, UP<u64, u64>>(&mut txn).unwrap();
let env = Env::new_anon(409_600_000, 1).unwrap();
let mut txn = Env::mut_txn_begin(&env).unwrap();
let mut db2 = create_db_::<MutTxn<&Env, ()>, u64, u64, UP<u64, u64>>(&mut txn).unwrap();
println!("unsized length = {:?}", (txn.length >> 12) - len);
add_refs(&txn, &db, &mut refs).unwrap();
for (p, r) in refs.iter() {
if *r >= 2 {
error!("{:?} referenced twice", p);
err += 1
}
}
assert_eq!(err, 0);
refs.clear();
add_refs(&txn, &db2, &mut refs).unwrap();
add_free_refs_mut(&mut txn, &mut refs).unwrap();
//!
//! Here's an example of how to use it (starting with 64 pages, 2
//! versions, see below for details about what that means). The file
//! grows automatically, as needed.
//!
//! ```
//! use sanakirja::*;
//! let dir = tempfile::tempdir().unwrap();
//! let path = dir.path().join("db");
//! let env = Env::new(&path, 1 << 20, 2).unwrap();
//! let mut txn = Env::mut_txn_begin(&env).unwrap();
//! let mut db = btree::create_db::<_, u64, u64>(&mut txn).unwrap();
//! for i in 0..100_000u64 {
//! btree::put(&mut txn, &mut db, &i, &(i*i)).unwrap();
//! }
//! let root_db = 0;
//! txn.set_root(root_db, db.db);
//! txn.commit().unwrap();
//! let txn = Env::txn_begin(&env).unwrap();
//! let db: btree::Db<u64, u64> = txn.root_db(root_db).unwrap();
//! assert_eq!(btree::get(&txn, &db, &50_000, None).unwrap(), Some((&50_000, &(50_000 * 50_000))));
//! for entry in btree::iter(&txn, &db, None).unwrap() {
//! let (k, v) = entry.unwrap();
//! assert_eq!(*k * *k, *v)
//! }
//! ```
let env = txn.env.borrow();
unsafe {
let p = &*(env.mmaps.lock()[0].ptr.add(txn.root * PAGE_SIZE)
as *const crate::environment::GlobalHeader);
if p.free_db != 0 {
debug!("add_free_refs: free = 0x{:x}", p.free_db);
let free_db: Db<u64, ()> = btree::Db::from_page(p.free_db);
add_refs(txn, &free_db, pages)?;
}
if p.rc_db != 0 {
debug!("add_free_refs: rc = 0x{:x}", p.rc_db);
let rc_db: Db<u64, ()> = btree::Db::from_page(p.rc_db);
add_refs(txn, &rc_db, pages)?;
}
};
if txn.free != 0 {
debug!("add_free_refs: free = 0x{:x}", txn.free);
let free_db: Db<u64, ()> = btree::Db::from_page(txn.free);
add_refs(txn, &free_db, pages)?;
}
if let Some(ref rc) = txn.rc {
debug!("add_free_refs: rc = 0x{:x}", rc.db);
add_refs(txn, &rc, pages)?;
}