Search in sources :

Example 51 with Cursor

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());
        }
    }
}
Also used : Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 52 with Cursor

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());
}
Also used : Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 53 with Cursor

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());
}
Also used : Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 54 with Cursor

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());
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 55 with Cursor

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());
}
Also used : Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Aggregations

Cursor (jetbrains.exodus.env.Cursor)57 Test (org.junit.Test)46 ByteIterable (jetbrains.exodus.ByteIterable)7 ArrayByteIterable (jetbrains.exodus.ArrayByteIterable)6 NotNull (org.jetbrains.annotations.NotNull)4 Store (jetbrains.exodus.env.Store)3 Transaction (jetbrains.exodus.env.Transaction)3 File (java.io.File)2 TestFor (jetbrains.exodus.TestFor)2 TransactionalExecutable (jetbrains.exodus.env.TransactionalExecutable)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 ComparableBinding (jetbrains.exodus.bindings.ComparableBinding)1 Job (jetbrains.exodus.core.execution.Job)1 JobProcessor (jetbrains.exodus.core.execution.JobProcessor)1 BlobsTable (jetbrains.exodus.entitystore.tables.BlobsTable)1 PropertyValue (jetbrains.exodus.entitystore.tables.PropertyValue)1 TreeCursorNoDuplicatesTest (jetbrains.exodus.tree.TreeCursorNoDuplicatesTest)1