Search in sources :

Example 41 with Cursor

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

Example 42 with Cursor

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

Example 43 with Cursor

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

Example 44 with Cursor

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

Example 45 with Cursor

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