use of jetbrains.exodus.tree.INode in project xodus by JetBrains.
the class BTreeTest method testGetReturnsFirstSortedDuplicate.
@Test
public void testGetReturnsFirstSortedDuplicate() throws IOException {
tm = new BTreeEmpty(log, createTestSplittingPolicy(), true, 1).getMutableCopy();
List<INode> l = new ArrayList<>();
l.add(kv("1", "1"));
l.add(kv("2", "2"));
l.add(kv("3", "3"));
l.add(kv("5", "51"));
l.add(kv("5", "52"));
l.add(kv("5", "53"));
l.add(kv("5", "54"));
l.add(kv("5", "55"));
l.add(kv("5", "56"));
l.add(kv("5", "57"));
l.add(kv("7", "7"));
for (INode ln : l) {
getTreeMutable().add(ln);
}
valueEquals("51", tm.get(key("5")));
}
use of jetbrains.exodus.tree.INode in project xodus by JetBrains.
the class BTreeTest method testSplitRandom.
@Test
public void testSplitRandom() throws IOException {
int s = 10000;
List<INode> lns = createLNs(s);
tm = new BTreeEmpty(log, createTestSplittingPolicy(), true, 1).getMutableCopy();
while (!lns.isEmpty()) {
final int index = (int) (Math.random() * lns.size());
INode ln = lns.get(index);
getTreeMutable().put(ln);
lns.remove(index);
}
checkTree(getTreeMutable(), s).run();
long rootAddress = saveTree();
checkTree(getTreeMutable(), s).run();
reopen();
t = new BTree(log, rootAddress, true, 1);
checkTree(getTree(), s).run();
}
use of jetbrains.exodus.tree.INode in project xodus by JetBrains.
the class BTreeTest method testPutAndDelete.
@Test
public void testPutAndDelete() throws IOException {
tm = new BTreeEmpty(log, createTestSplittingPolicy(), true, 1).getMutableCopy();
for (int i = 0; i < 100; i++) {
getTreeMutable().put(kv(i, "v" + i));
}
long rootAddress = saveTree();
tm = new BTree(log, getTreeMutable().getBalancePolicy(), rootAddress, true, 1).getMutableCopy();
checkTree(getTreeMutable(), 100).run();
for (int i = 0; i < 100; i++) {
getTreeMutable().put(kv(i, "v" + i));
}
Assert.assertEquals(1L, (long) tm.getExpiredLoggables().size());
for (int i = 0; i < 100; i++) {
final INode ln = kv(i, "v" + i);
getTreeMutable().delete(ln.getKey(), ln.getValue());
}
Assert.assertEquals(0, tm.getSize());
assertMatchesIterator(tm, Collections.<INode>emptyList());
rootAddress = saveTree();
reopen();
t = new BTree(log, rootAddress, true, 1);
assertMatchesIterator(tm, Collections.<INode>emptyList());
}
Aggregations