use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorNoDuplicatesTest method testGetSearchKeyRange3.
@Test
public void testGetSearchKeyRange3() throws IOException {
tm = createMutableTree(false, 1);
getTreeMutable().put(new ArrayByteIterable(new byte[] { 1 }), value("v1"));
final ArrayByteIterable key = new ArrayByteIterable(new byte[] { 1, 2, 1, 0 });
getTreeMutable().put(key, value("v2"));
Cursor c = getTreeMutable().openCursor();
assertEquals(value("v2"), c.getSearchKeyRange(new ArrayByteIterable(new byte[] { 1, 2, 1 })));
assertEquals(key, c.getKey());
assertFalse(c.getNext());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorNoDuplicatesTest method testGetNext3.
@Test
public void testGetNext3() throws IOException {
tm = createMutableTree(false, 1);
for (int i = 0; i < 1000; i++) {
getTreeMutable().put(kv(i, "v" + i));
}
Cursor c = getTreeMutable().openCursor();
assertEquals(value("v998"), c.getSearchKey(key(998)));
// v999 - last
assertTrue(c.getNext());
assertFalse(c.getNext());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorNoDuplicatesTest method testGetNext2.
@Test
public void testGetNext2() throws IOException {
tm = createMutableTree(false, 1);
getTreeMutable().put(kv(1, "v1"));
getTreeMutable().put(kv(2, "v2"));
getTreeMutable().put(kv(3, "v3"));
getTreeMutable().put(kv(4, "v4"));
getTreeMutable().put(kv(5, "v5"));
Cursor c = getTreeMutable().openCursor();
assertEquals(value("v5"), c.getSearchKey(key(5)));
assertFalse(c.getNext());
long a = saveTree();
c = getTreeMutable().openCursor();
assertEquals(value("v5"), c.getSearchKey(key(5)));
assertFalse(c.getNext());
t = openTree(a, false);
c = getTreeMutable().openCursor();
assertEquals(value("v5"), c.getSearchKey(key(5)));
assertFalse(c.getNext());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorNoDuplicatesTest method testSplitRange.
@Test
public void testSplitRange() throws IOException {
tm = getTreeMutable().getMutableCopy();
getTreeMutable().put(key("aaabbb"), value("v10"));
getTreeMutable().put(key("aaaddd"), value("v20"));
Cursor c = getTreeMutable().openCursor();
assertNotNull(c.getSearchKeyRange(key("aaa")));
assertEquals(value("v10"), c.getValue());
assertNull(c.getSearchKey(key("aaa")));
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class TreeCursorNoDuplicatesTest method testGetSearchBoth.
@Test
public void testGetSearchBoth() throws IOException {
Cursor c = getTreeMutable().openCursor();
for (int i = 0; i < s; i++) {
assertEquals(true, c.getSearchBoth(key(i), value("v" + i)));
assertEquals(c.getValue(), value("v" + i));
assertEquals(c.getKey(), key(i));
}
assertFalse(c.getNext());
}
Aggregations