use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorDuplicatesTest method testGetNextNoDup2.
@Test
public void testGetNextNoDup2() throws IOException {
Cursor c = tm.openCursor();
assertEquals(value("v1"), c.getSearchKey(key(1)));
assertFalse(c.getNextDup());
// 51
c.getSearchKey(key(5));
c.deleteCurrent();
assertTrue(c.getNextNoDup());
assertEquals(key(7), c.getKey());
assertEquals(value("v7"), c.getValue());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorDuplicatesTest method testGetSearchKeyRange2.
@Test
public void testGetSearchKeyRange2() throws IOException {
final TreeAwareRunnable getSearchKeyRange = new TreeAwareRunnable(getTreeMutable()) {
@Override
public void run() {
Cursor c = _t.openCursor();
assertEquals(value("v1"), c.getSearchKeyRange(key(0)));
assertEquals(key(1), c.getKey());
assertEquals(value("v51"), c.getSearchKeyRange(key(3)));
assertEquals(key(5), c.getKey());
assertEquals(true, c.getNextDup());
assertEquals(value("v52"), c.getValue());
assertEquals(key(5), c.getKey());
assertEquals(true, c.getNextDup());
assertEquals(value("v53"), c.getValue());
assertEquals(key(5), c.getKey());
assertEquals(null, c.getSearchKeyRange(key(13)));
// cursor keep prev pos
assertEquals(value("v53"), c.getValue());
assertEquals(key(5), c.getKey());
}
};
getSearchKeyRange.run();
long a = saveTree();
getSearchKeyRange.run();
reopen();
getSearchKeyRange.setTree(openTree(a, true));
getSearchKeyRange.run();
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorDuplicatesTest method testGetPrev2.
@Test
public void testGetPrev2() throws IOException {
tm = createMutableTree(true, 1);
values.clear();
values.add(kv(0, "v0"));
values.add(kv(0, "v1"));
values.add(kv(1, "v1"));
for (INode ln : values) {
getTreeMutable().put(ln);
valuesNoDup.add(ln);
}
final TreeAwareRunnable getPrev = new TreeAwareRunnable(getTreeMutable()) {
@Override
public void run() {
Cursor c = _t.openCursor();
final ListIterator<INode> itr = values.listIterator(values.size());
while (itr.hasPrevious()) {
INode ln = itr.previous();
assertEquals(true, c.getPrev());
assertEquals(ln.getValue(), c.getValue());
assertEquals(ln.getKey(), c.getKey());
}
assertEquals(false, c.getPrev());
}
};
getPrev.run();
long a = saveTree();
getPrev.run();
reopen();
getPrev.setTree(openTree(a, true));
getPrev.run();
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorDuplicatesTest method testGetSearchBothRange1.
@Test
public void testGetSearchBothRange1() throws IOException {
final TreeAwareRunnable getSearchBothRange = new TreeAwareRunnable(getTreeMutable()) {
@Override
public void run() {
Cursor c = _t.openCursor();
for (INode ln : values) {
assertEquals(ln.getValue(), c.getSearchBothRange(ln.getKey(), ln.getValue()));
assertEquals(ln.getValue(), c.getValue());
assertEquals(ln.getKey(), c.getKey());
}
}
};
getSearchBothRange.run();
long a = saveTree();
getSearchBothRange.run();
reopen();
getSearchBothRange.setTree(openTree(a, true));
getSearchBothRange.run();
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorNoDuplicatesTest method testGetSearchKeyRange1.
@Test
public void testGetSearchKeyRange1() throws IOException {
Cursor c = getTreeMutable().openCursor();
for (int i = 0; i < s; i++) {
assertEquals(value("v" + i), c.getSearchKeyRange(key(i)));
assertEquals(c.getValue(), value("v" + i));
assertEquals(c.getKey(), key(i));
}
assertFalse(c.getNext());
}
Aggregations