Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

KeyRange.greaterThanBackward() not working? #89

Copy link
Copy link
@archiecobbs

Description

@archiecobbs
Issue body actions

Either I am not understanding something, or else KeyRange.greaterThanBackward() is broken.

The following test fails:

import java.io.*;

import org.lmdbjava.*;
import org.testng.Assert;
import org.testng.annotations.Test;

public class FooTest {

    @Test
    public void testFoo() throws Exception {

        // Create new empty directory
        File dir = File.createTempFile("foo.", null);
        Assert.assertTrue(dir.delete());
        Assert.assertTrue(dir.mkdirs());
        dir.deleteOnExit();

        // Create new environment
        Env.Builder<byte[]> builder = Env.create(ByteArrayProxy.PROXY_BA);
        Env<byte[]> env = builder.open(dir);

        // Open database
        Dbi<byte[]> db = env.openDbi("foo", DbiFlags.MDB_CREATE);

        // Open transaction
        Txn<byte[]> tx = env.txnWrite();

        // Put key/value pair
        db.put(tx, new byte[] { 1 }, new byte[] { 2 });

        // Iterate range backwards - we should encounter the key/value pair we just put
        try (CursorIterator<byte[]> i = db.iterate(tx, KeyRange.greaterThanBackward(new byte[] { 3 }))) {
            Assert.assertTrue(i.hasNext());      // TEST FAILS HERE
            CursorIterator.KeyVal<byte[]> kv = i.next();
            Assert.assertEquals(kv.key(), new byte[] { 1 });
            Assert.assertEquals(kv.val(), new byte[] { 2 });
            Assert.assertFalse(i.hasNext());
        }

        // Commit transaction
        tx.commit();

        // Close environment
        env.close();
    }
}

What am I missing? Thanks.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.