Search in sources :

Example 11 with Cursor

use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.

the class TreeCursorNoDuplicatesTest method testGetSearchBothRange1.

@Test
public void testGetSearchBothRange1() throws IOException {
    Cursor c = getTreeMutable().openCursor();
    for (int i = 0; i < s; i++) {
        assertEquals(value("v" + i), c.getSearchBothRange(key(i), value("v" + i)));
        assertEquals(c.getValue(), value("v" + i));
        assertEquals(c.getKey(), key(i));
    }
}
Also used : Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 12 with Cursor

use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.

the class TreeCursorNoDuplicatesTest method testGetSearchKey.

@Test
public void testGetSearchKey() throws IOException {
    Cursor c = getTreeMutable().openCursor();
    for (int i = 0; i < s; i++) {
        assertEquals("v" + i, value("v" + i), c.getSearchKey(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)

Example 13 with Cursor

use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.

the class TreeCursorNoDuplicatesTest method testGetSearchKeyRange5.

@Test
public void testGetSearchKeyRange5() throws IOException {
    tm = createMutableTree(false, 1);
    final ByteIterable v = value("0");
    tm.put(key("aaba"), v);
    tm.put(key("aabb"), v);
    Cursor c = tm.openCursor();
    assertNotNull(c.getSearchKeyRange(key("aababa")));
    assertEquals(key("aabb"), c.getKey());
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 14 with Cursor

use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.

the class TreeCursorNoDuplicatesTest method testGetSearchKeyRange4.

@Test
public void testGetSearchKeyRange4() throws IOException {
    tm = createMutableTree(false, 1);
    final ByteIterable v = value("0");
    tm.put(key("aaaa"), v);
    tm.put(key("aaab"), v);
    tm.put(key("aaba"), v);
    Cursor c = tm.openCursor();
    c.getSearchKeyRange(key("aaac"));
    assertEquals(key("aaba"), c.getKey());
}
Also used : ByteIterable(jetbrains.exodus.ByteIterable) ArrayByteIterable(jetbrains.exodus.ArrayByteIterable) Cursor(jetbrains.exodus.env.Cursor) Test(org.junit.Test)

Example 15 with Cursor

use of jetbrains.exodus.env.Cursor in project xodus by JetBrains.

the class TreeCursorNoDuplicatesTest method testGetSearchKeyRange2.

@Test
public void testGetSearchKeyRange2() throws IOException {
    tm = createMutableTree(false, 1);
    getTreeMutable().put(key("10"), value("v10"));
    getTreeMutable().put(key("20"), value("v20"));
    getTreeMutable().put(key("30"), value("v30"));
    getTreeMutable().put(key("40"), value("v40"));
    getTreeMutable().put(key("50"), value("v50"));
    getTreeMutable().put(key("60"), value("v60"));
    Cursor c = getTreeMutable().openCursor();
    assertEquals(value("v10"), c.getSearchKeyRange(key("01")));
    assertEquals(key("10"), c.getKey());
    assertEquals(value("v60"), c.getSearchKeyRange(key("55")));
    assertEquals(key("60"), c.getKey());
    assertEquals(null, c.getSearchKeyRange(key("61")));
    // cursor keep prev pos
    assertEquals(key("60"), c.getKey());
    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