use of jetbrains.exodus.log.Loggable in project xodus by JetBrains.
the class BTreeReclaimTest method testLeafDup.
@Test
public void testLeafDup() {
int p;
int u;
long rootAddress = initDup(p = 10, u = 100);
tm = ((BTree) (t = new BTree(log, getTreeMutable().getBalancePolicy(), rootAddress, true, 1))).getMutableCopy();
final ByteIterable key = key(0);
final ByteIterable value = value("v0#10");
final LeafNodeDup dupLeaf = (LeafNodeDup) getTree().getRoot().get(key);
Assert.assertNotNull(dupLeaf);
final BTreeDup dt = dupLeaf.tree;
final ILeafNode savedLeaf = dt.getRoot().get(value);
Assert.assertNotNull(savedLeaf);
final Iterator<RandomAccessLoggable> iter = log.getLoggableIterator(savedLeaf.getAddress());
Assert.assertTrue(tm.reclaim(iter.next(), iter));
final AddressIterator addressIterator = getTreeAddresses(getTree());
final LeafNodeDupMutable dupLeafMutable = (LeafNodeDupMutable) getTreeMutable().getRoot().get(key);
Assert.assertNotNull(dupLeafMutable);
final BTreeDupMutable dtm = dupLeafMutable.tree;
while (addressIterator.hasNext()) {
final long address = addressIterator.next();
final Loggable loggable = log.read(address);
if (BTreeTraverser.isInDupMode(addressIterator) && isAffected(loggable, key, BTreeTraverser.getTraverserNoDup(addressIterator))) {
assertAffected(dtm, dt, loggable, value, (BTreeTraverser) addressIterator.getTraverser());
}
}
checkTree(tm = ((BTree) (t = new BTree(log, getTreeMutable().getBalancePolicy(), rootAddress, true, 1))).getMutableCopy(), p, u).run();
}
use of jetbrains.exodus.log.Loggable in project xodus by JetBrains.
the class BTreeReclaimTest method testDupLeaf.
@Test
public void testDupLeaf() {
int p;
int u;
long rootAddress = initDup(p = 10, u = 100);
tm = ((BTree) (t = new BTree(log, getTreeMutable().getBalancePolicy(), rootAddress, true, 1))).getMutableCopy();
final ByteIterable key = key(0);
final ILeafNode savedLeaf = getTree().getRoot().get(key);
Assert.assertNotNull(savedLeaf);
final Iterator<RandomAccessLoggable> iter = log.getLoggableIterator(savedLeaf.getAddress());
Assert.assertTrue(tm.reclaim(iter.next(), iter));
final AddressIterator addressIterator = getTreeAddresses(getTree());
while (addressIterator.hasNext()) {
final long address = addressIterator.next();
isAffected(log.read(address), key, (BTreeTraverser) addressIterator.getTraverser());
final Loggable loggable = log.read(address);
if (BTreeTraverser.isInDupMode(addressIterator) && isAffected(loggable, key, BTreeTraverser.getTraverserNoDup(addressIterator))) {
assertAffected(getTreeMutable(), getTree(), loggable, key);
}
}
rootAddress = saveTree();
checkTree(tm = ((BTree) (t = new BTree(log, getTreeMutable().getBalancePolicy(), rootAddress, true, 1))).getMutableCopy(), p, u).run();
}
Aggregations