GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — KeyRange.greaterThanBackward() not working? · Issue #89 · lmdbjava/lmdbjava

KeyRange.greaterThanBackward() not working? #89

New issue
Copy link
New issue
Copy link
Closed
Closed
KeyRange.greaterThanBackward() not working?#89
Copy link

Description

@archiecobbs
archiecobbs
opened on Apr 22, 2018
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.

Activity

  1. bp-alex commented on Apr 22, 2018

    @bp-alex
    bp-alex
    on Apr 22, 2018
    Member
    More actions

    Please see ticket #86 and give it a try with 0.6.1-SNAPSHOT.

  2. archiecobbs commented on Apr 23, 2018

    @archiecobbs
    archiecobbs
    on Apr 23, 2018
    Author
    More actions

    I've confirmed that 0.6.1-SNAPSHOT resolves this bug. Thanks.

  3. archiecobbs
    closed this as completedon Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.