Search in sources :

Example 36 with Cursor

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

Example 37 with Cursor

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

Example 38 with Cursor

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

Example 39 with Cursor

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

Example 40 with Cursor

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());
}
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