use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class BTreeCursorDeleteTest method testDeleteCursorDuplicates3.
@Test
public void testDeleteCursorDuplicates3() throws IOException {
tm = createMutableTree(true, 1).getMutableCopy();
for (int i = 0; i < 32; ++i) {
for (int j = 0; j < 32; ++j) {
getTreeMutable().put(IntegerBinding.intToEntry(i), IntegerBinding.intToEntry(j));
}
}
for (int i = 0; i < 32; ++i) {
final Cursor cursor = getTreeMutable().openCursor();
Assert.assertNotNull(cursor.getSearchKeyRange(IntegerBinding.intToEntry(i)));
for (int j = 0; j < 31; ++j) {
cursor.deleteCurrent();
Assert.assertTrue(cursor.getNext());
}
}
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class BTreeCursorDeleteTest method testDeleteCursorDuplicates2.
@Test
public void testDeleteCursorDuplicates2() throws IOException {
tm = createEmptyTreeForCursor(1).getMutableCopy();
for (int i = 0; i < 8; i++) {
getTreeMutable().put(kv(i, "v" + i));
getTreeMutable().put(kv(i, "vv" + i));
}
Cursor c = getTreeMutable().openCursor();
assertEquals(true, c.getSearchBoth(key(1), value("vv1")));
assertTrue(c.deleteCurrent());
assertFalse(c.deleteCurrent());
assertTrue(c.getNext());
assertEquals(true, c.getSearchBoth(key(7), value("vv7")));
assertTrue(c.deleteCurrent());
assertFalse(c.getNext());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class BTreeCursorDeleteTest method testDeleteCursorNoDuplicates2.
@Test
public void testDeleteCursorNoDuplicates2() throws IOException {
tm = createEmptyTreeForCursor(1).getMutableCopy();
for (int i = 0; i < 8; i++) {
getTreeMutable().put(kv(i, "v" + i));
}
Cursor c = tm.openCursor();
assertTrue(c.getNext());
assertEquals(key(0), c.getKey());
assertTrue(c.deleteCurrent());
assertFalse(c.deleteCurrent());
assertTrue(c.getNext());
assertEquals(key(1), c.getKey());
assertEquals(value("v7"), c.getSearchKey(key(7)));
assertTrue(c.deleteCurrent());
assertFalse(c.deleteCurrent());
assertFalse(c.getNext());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class BTreeCursorDupConcurrentModificationTest method testConcurrentDeleteCurrent.
@Test
public void testConcurrentDeleteCurrent() {
Cursor c = tm.openCursor();
final ByteIterable value = value("v51");
assertTrue(c.getSearchBoth(key(5), value));
deleteImpl(key(5), value);
assertTrue(c.getNext());
assertEquals(key(5), c.getKey());
assertEquals(value("v52"), c.getValue());
}
use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.
the class BTreeCursorDupConcurrentModificationTest method testConcurrentDeleteBefore1.
@Test
public void testConcurrentDeleteBefore1() {
Cursor c = tm.openCursor();
assertTrue(c.getSearchBoth(key(5), value("v51")));
deleteImpl(key(1));
assertTrue(c.getNext());
assertEquals(key(5), c.getKey());
assertEquals(value("v52"), c.getValue());
assertTrue(c.getNext());
assertEquals(key(6), c.getKey());
}
Aggregations