Search in sources :

Example 11 with INode

use of jetbrains.exodus.tree.INode in project xodus by JetBrains.

the class BTreeTest method testPutSortDuplicates.

@Test
public void testPutSortDuplicates() throws IOException {
    tm = new BTreeEmpty(log, createTestSplittingPolicy(), true, 1).getMutableCopy();
    List<INode> expected = new ArrayList<>();
    expected.add(kv("1", "1"));
    expected.add(kv("2", "2"));
    expected.add(kv("3", "3"));
    expected.add(kv("5", "51"));
    expected.add(kv("5", "52"));
    expected.add(kv("5", "53"));
    expected.add(kv("5", "54"));
    expected.add(kv("5", "55"));
    expected.add(kv("5", "56"));
    expected.add(kv("5", "57"));
    expected.add(kv("7", "7"));
    for (INode ln : expected) {
        getTreeMutable().put(ln);
    }
    assertMatchesIterator(tm, expected);
}
Also used : INode(jetbrains.exodus.tree.INode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 12 with INode

use of jetbrains.exodus.tree.INode in project xodus by JetBrains.

the class BTreeTest method testPutRightSortDuplicates.

@Test
public void testPutRightSortDuplicates() throws IOException {
    tm = new BTreeEmpty(log, createTestSplittingPolicy(), true, 1).getMutableCopy();
    List<INode> expected = new ArrayList<>();
    expected.add(kv("1", "1"));
    expected.add(kv("2", "2"));
    expected.add(kv("3", "3"));
    expected.add(kv("5", "51"));
    expected.add(kv("5", "52"));
    expected.add(kv("5", "53"));
    expected.add(kv("5", "54"));
    expected.add(kv("5", "55"));
    expected.add(kv("5", "56"));
    expected.add(kv("5", "57"));
    expected.add(kv("7", "7"));
    for (INode ln : expected) {
        getTreeMutable().putRight(ln);
    }
    assertMatchesIterator(tm, expected);
}
Also used : INode(jetbrains.exodus.tree.INode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with INode

use of jetbrains.exodus.tree.INode in project xodus by JetBrains.

the class BTreeNoDuplicatesExpiredAddressesTest method testDelete.

@Test
public void testDelete() throws IOException {
    tm = new BTreeEmpty(log, false, 1).getMutableCopy();
    INode leafNode = kv(0, "value");
    getTreeMutable().put(leafNode);
    checkExpiredAddress(tm, 0, "Expired: none");
    long address = saveTree();
    t = new BTree(log, address, false, 1);
    tm = getTree().getMutableCopy();
    tm.delete(leafNode.getKey());
    checkExpiredAddress(tm, 2, "Expired: root, value");
    saveTree();
}
Also used : INode(jetbrains.exodus.tree.INode) Test(org.junit.Test)

Example 14 with INode

use of jetbrains.exodus.tree.INode in project xodus by JetBrains.

the class BTreeDuplicatesExpiredAddressesTest method testDeleteSingleConvert.

@Test
public void testDeleteSingleConvert() throws IOException {
    tm = new BTreeEmpty(log, true, 1).getMutableCopy();
    getTreeMutable().put(kv(0, "value"));
    INode leafNode = kv(0, "value2");
    getTreeMutable().put(leafNode);
    // Expired: none
    checkExpiredAddress(tm, 0);
    long address = saveTree();
    t = new BTree(log, address, true, 1);
    tm = getTree().getMutableCopy();
    AddressIterator it = getTreeMutable().addressIterator();
    System.out.println("Before delete:");
    dumplLoggable(it);
    getTreeMutable().delete(leafNode.getKey(), leafNode.getValue());
    // Expired: root, dupTree, value, value2
    checkExpiredAddress(tm, 4);
    saveTree();
}
Also used : INode(jetbrains.exodus.tree.INode) Test(org.junit.Test)

Example 15 with INode

use of jetbrains.exodus.tree.INode in project xodus by JetBrains.

the class BTreeDuplicatesExpiredAddressesTest method testDeleteAllDups.

@Test
public void testDeleteAllDups() throws IOException {
    tm = new BTreeEmpty(log, true, 1).getMutableCopy();
    getTreeMutable().put(kv(0, "value"));
    // Expired: none
    checkExpiredAddress(tm, 0);
    INode leafNode = kv(0, "value2");
    getTreeMutable().put(leafNode);
    // Expired: still none (changes in memory)
    checkExpiredAddress(tm, 0);
    long address = saveTree();
    t = new BTree(log, address, true, 1);
    tm = getTree().getMutableCopy();
    tm.delete(leafNode.getKey());
    // Expired: root, dupTree, value, value2
    checkExpiredAddress(tm, 4);
    saveTree();
}
Also used : INode(jetbrains.exodus.tree.INode) Test(org.junit.Test)

Aggregations

INode (jetbrains.exodus.tree.INode)18 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)6 ByteIterable (jetbrains.exodus.ByteIterable)1