KX3WVNZW5KHVEH6EOQTZ4RBEFFJ3SGF5I467X3JWZ74PURRK4HVAC
JEHCE5FNOINH47N5MZ2I7JP7DKGN24PW5TVDRVALRPZHTIQCMMDQC
6DCQHIFPEH4GZKSRRS32GMKDRPZH4MTCGOUEI7YEUVKWENBF3JWAC
H3FVSQIQGFCFKCPXVOSFHP4OSUOBBURJESCZNGQTNDAAD3WQSBEQC
AOX2XQISHGWNNAFBYRN44Q6AWG7H5DPBK5YMFHK42HQNZ2TMHEJQC
OP6SVMOD2GTQ7VNJ4E5KYFG4MIYA7HBMXJTADALMZH4PY7OQRMZQC
DV4A2LR7Q5LAEGAQHLO34PZCHGJUHPAMRZFGT7GUFNKVQKPJNOYQC
QEUTVAZ4F4EJXRDMWDMYXF6XEDMX7YPVG4IIXEKPIR3K54E5W5OAC
OTWDDJE7TTE73D6BGF4ZN6BH2NFUFLPME2VJ3CPALH463UGWLEIQC
UUUVNC4DWEEL7WV5IRPKPZ6HZMYCPA53XM7LJWICUD4E6GN37IRQC
6UVFCERMGSGNRWCVC3GWO5HWV6MSWE433DXBJVC7KRPP6LLJLCSQC
UAQX27N4PI4LHEW6LSHJETIE5MV7JTEMPLTJFYUBMYVPC43H7VOAC
let mut n = header(new_left.0.as_page()).n() as isize;
alloc::<K, V, L>(&mut new_left, m.mid.0, m.mid.1, 0, rl, &mut n);
let hdrl = header(new_left.0.as_page());
debug!("mid = {:?}", m.mid);
let mut lc = <Page<K, V>>::last_cursor(m.modified.page.as_page());
<Page<K, V>>::move_next(m.modified.page.as_page(), &mut lc);
if let Put::Ok(Ok { page, freed }) =
<Page<K, V>>::put(txn, new_left.0, true, &lc, m.mid.0, m.mid.1, None, 0, rl)?
{
if freed > 0 {
let b = if header(new_left.0.as_page()).is_dirty() {
1
} else {
0
};
freed_[0] = freed | b;
}
new_left = page
} else {
unreachable!()
};
alloc::<K, V, L>(&mut new_left, m.mid.0, m.mid.1, 0, rl, &mut n);
let mut lc = <Page<K, V>>::last_cursor(m.modified.page.as_page());
<Page<K, V>>::move_next(m.modified.page.as_page(), &mut lc);
if let Put::Ok(Ok { page, freed }) =
<Page<K, V>>::put(txn, new_left.0, true, &lc, m.mid.0, m.mid.1, None, 0, rl)?
{
if freed > 0 {
let b = if header(new_left.0.as_page()).is_dirty() {
1
} else {
0
};
freed_[0] = freed | b;
}
new_left = page
} else {
unreachable!()
};
impl<K: Representable + ?Sized + core::fmt::Debug, V: Representable + ?Sized + core::fmt::Debug, P: BTreePage<K, V>> Cursor<K, V, P> {
impl<
K: Representable + ?Sized + core::fmt::Debug,
V: Representable + ?Sized + core::fmt::Debug,
P: BTreePage<K, V>,
> Cursor<K, V, P>
{
#[test]
fn split_on_del() {
env_logger::try_init().unwrap_or(());
let env = Env::new_anon(409600000, 1).unwrap();
let mut txn = Env::mut_txn_begin(&env).unwrap();
let mut db = create_db_::<MutTxn<&Env, ()>, u64, [u8], UP<u64, [u8]>>(&mut txn).unwrap();
for i in (0..157).step_by(10) {
for i in i..i + 4 {
let a = [b'a'; 500];
put(&mut txn, &mut db, &i, &a[..]).unwrap();
}
put(&mut txn, &mut db, &(i + 9), &[b'b'; 254]).unwrap();
}
for i in (0..157).step_by(10) {
for i in i + 4..i + 7 {
let a = [b'a'; 500];
put(&mut txn, &mut db, &i, &a[..]).unwrap();
}
}
crate::debug::debug(&txn, &[&db], "debug0", true);
for i in 0..4 {
debug!("============ deleting {:?}", i);
del(&mut txn, &mut db, &i, None).unwrap();
}
crate::debug::debug(&txn, &[&db], "debug1", true);
del(&mut txn, &mut db, &4, None).unwrap();
crate::debug::debug(&txn, &[&db], "debug2", true);
}
#[test]
fn split_on_del2() {
env_logger::try_init().unwrap_or(());
let env = Env::new_anon(409600000, 1).unwrap();
let mut txn = Env::mut_txn_begin(&env).unwrap();
let mut db = create_db_::<MutTxn<&Env, ()>, u64, [u8], UP<u64, [u8]>>(&mut txn).unwrap();
for i in (0..157).step_by(10) {
for i in i..i + 4 {
let a = [b'a'; 500];
put(&mut txn, &mut db, &i, &a[..]).unwrap();
}
put(&mut txn, &mut db, &(i + 9), &[b'b'; 255]).unwrap();
}
for i in (0..157).step_by(10) {
for i in i + 4..i + 7 {
let a = [b'a'; 500];
put(&mut txn, &mut db, &i, &a[..]).unwrap();
}
}
crate::debug::debug(&txn, &[&db], "debug0", true);
del(&mut txn, &mut db, &0, None).unwrap();
crate::debug::debug(&txn, &[&db], "debug1", true);
}