Search in sources :

Example 1 with Loggable

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();
}
Also used : RandomAccessLoggable(jetbrains.exodus.log.RandomAccessLoggable) RandomAccessLoggable(jetbrains.exodus.log.RandomAccessLoggable) Loggable(jetbrains.exodus.log.Loggable) ByteIterable(jetbrains.exodus.ByteIterable) Test(org.junit.Test)

Example 2 with Loggable

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();
}
Also used : RandomAccessLoggable(jetbrains.exodus.log.RandomAccessLoggable) Loggable(jetbrains.exodus.log.Loggable) ByteIterable(jetbrains.exodus.ByteIterable) RandomAccessLoggable(jetbrains.exodus.log.RandomAccessLoggable) Test(org.junit.Test)

Aggregations

ByteIterable (jetbrains.exodus.ByteIterable)2 Loggable (jetbrains.exodus.log.Loggable)2 RandomAccessLoggable (jetbrains.exodus.log.RandomAccessLoggable)2 Test (org.junit.Test)2