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 — Remove MDB_UNSIGNEDKEY, add a builder for Dbi, add MDB_INTEGERKEY comparators by at055612 · Pull Request #276 · lmdbjava/lmdbjava

Conversation

@at055612

@at055612 at055612 commented Nov 5, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Fixes #249
Fixes #267

Two fixes in one PR as both need each other.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
at055612 and others added 30 commits March 6, 2025 16:04
@at055612
gh-249 Remove MDB_UNSIGNEDKEY, let CursorIterable call mdb_cmp
480e984
There are now essentially three ways of configuring comparators
when creating a Dbi.

**null comparator**
LMDB will use its own comparator & CursorIterable will call down
to mdb_cmp for comparisons between the current cursor key and the
range start/stop key.

**provided comparator**
LMDB will use its own comparator & CursorIterable will use the
provided comparator for comparisons between the current cursor
key and the range start/stop key.

**provided comparator with nativeCb==true**
LMDB will call back to java for all comparator duties.
CursorIterable will use the same provided comparator for
comparisons between the current cursor key and the range
start/stop key.

The methods `getSignedComparator()` and `getUnsignedComparator()`
have been made public so users of this library can access them.
@at055612
gh-249 Remove non-J8 features, use indent size 2
46f8d08
@at055612
gh-249 Fix indents
f92012e
@at055612
gh-249 Tidy code and refactor RangeComparator impls
e1756d6
@at055612
gh-249 Remove commented code
9509f6b
@at055612
gh-249 Add CursorIterableIntegerKeyTest
67e2df1
@at055612
gh-249 Remove MaskedFlag.isPropagatedToLmdb, add DbiBuilder WIP
620a89f
@at055612
Merge branch 'master' into mdb_cmp
75d87d0
@at055612
Merge branch 'master' into mdb_cmp
47b4c4f
@at055612
Add FlagSet, DbiFlagSet, PutFlagSet
bfbf223
Refactor DbiBuilder and Dbi ctor to use DbiFlagSet.
@at055612
Rename FlagSet to AbstractFlagSet
0f66aaf
@at055612
Add remaining FlagSet impls
aa000a1
Replace Env#copy(File, CopyFlags...) with copy(File, CopyFlagSet).
As there is only one flag this should not be a breaking change.

Deprecate Env#txn(Txn, TxnFlags...) as there is now
Env#txn(Txn)
Env#txn(Txn, TxnFlags)
Env#txn(Txn, TxnFlagSet)
@at055612
Fix Javadoc
667dab3
@stroomdev66
Add more cursor tests to protect against future regression
b46c916
@at055612
Replace get(Uns|S)ignedComparator with getComparator(DbiFlagSet)
0234d32
Also improve javadoc and refactor some tests to use DbiBuilder.

Some tests are failing.
@at055612
Add missing txn commit in DbiBuilder
ef0c852
@at055612
Change CursorIterableTest to use Parameterized
1b3f94d
@at055612
Deprecate methods using varargs flags
c0bbe73
@at055612
Add int key compare method to (Direct|Byte)BufferProxy
4fd89ff
@stroomdev66
Merge branch 'master' of github.com:lmdbjava/lmdbjava into more-curso…
916b441
…r-tests
@at055612
Tidy code
58dcc6e
@at055612
Fix byte order issues with compareAsIntegerKeys
26665ba
@stroomdev66
#267 Fix to establish start key when iterating backwards from a start…
dc0b96b
… key using DUPSORT
@stroomdev66
Merge branch 'master' of github.com:lmdbjava/lmdbjava into gh-267
9db91a5
@at055612
Add/refactor tests
c427801
@at055612
Merge branch 'master' into mdb_cmp
f606e7e
@at055612
Add integer key comparator tests
e2be6bf
@stroomdev66
#267 Fix to establish start key when iterating backwards from a start…
7374fde
… key using DUPSORT
@stroomdev66
Merge branch 'master' of github.com:lmdbjava/lmdbjava into gh-267
79c0df6
@stroomdev66
#267 Fix to establish start key when iterating backwards from a start…
787d6d3
… key using DUPSORT
@bp-alex

bp-alex commented Nov 8, 2025

Copy link
Copy Markdown
Member

I have run the format plugin to sort out the whitespace and removed the separators for static inner classes (personally I think they improve readability but appreciate they are not everybody's cup of tea). Not a fan of some of the decisions that the formatter is making, but formatting is incredibly subjective so having automated opinionated formatting does make life easier in a shared code base.

We just use the Spotify fmt-maven-plugin which implements the Google Java Style (which is prescriptive and has no configuration options). I used to use PMD and Checkstyle on LmdbJava but I found it problematic because (a) every update would introduce new warnings which had to be suppressed for no apparent benefit and (b) they reflect options which are debatable at best and impeded people who wanted to provide PRs. I think the code formatter's prescriptive and automated approach strikes the right balance.

While this PR adds the Dbi builder, I decided to keep these methods for the really simple cases. The builder can be used for everything else more complicated. Hopefully a reasonable compromise.

  public Dbi<T> openDbi(final byte[] name, final DbiFlagSet dbiFlagSet) {
  }

  public Dbi<T> openDbi(final String name, final DbiFlagSet dbiFlagSet) {
  }

The builders are such a significant ergonomic improvement and given we are targeting 1.0.0 it might be a good opportunity to remove those methods to encourage visibility of the new golden path.

I have removed the ByteUnits dependency as that repo is no longer being maintained and we were only using a fraction of it and only in tests. I have replaced it with our own ByteUnit class and added new overloaded setMapSize methods to Env and Env.Builder to make it easier for users to specify larger sizes.

Excellent.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

at055612 added 4 commits November 9, 2025 19:20
@at055612
Change CursorIterableRangeTest to do default+native modes
a84ceaa
@at055612
Remove separator comments
a5e4cf2
@at055612
Add more tests to CursorIterableRangeTest
f8e6e07
@at055612
Remove unused test, auto format
6982aca
@at055612

at055612 commented Nov 12, 2025

Copy link
Copy Markdown
Collaborator Author

@benalexau

The builders are such a significant ergonomic improvement and given we are targeting 1.0.0 it might be a good opportunity to remove those methods to encourage visibility of the new golden path.

Originally I had deprecated all of the open( methods so the only route for Dbi creation was the builder, however I then started to think that for the simplest cases where you just want a named db with no special options, it would be worthwhile to keep the simplest of the open methods. i.e.

        env.createDbi()
            .setDbName("foo")
            .withDefaultComparator()
            .setDbiFlags(DbiFlags.MDB_CREATE)
            .open();

vs

env.open("foo", DbiFlags.MDB_CREATE)  // where MDB_CREATE is treated as a DbiFlagSet

The open(byte[], DbiFlagSet) variant can probably just be done via the builder as that seems like a less common use case.
Having this one open(String, DbiFlagSet) method may also reduce the amount of deprecation warnings people will see vs if it was deprecated.

I'm not too bothered either way so happy to go with whatever you decide.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

at055612 added 4 commits November 12, 2025 08:57
@at055612
Add tests to stop CodeQL warnings
6740e2b
@at055612
Auto format
0103f13
@at055612
Fix typo in javadoc
4249566
@at055612
Tidy code
35b0a9d
@bp-alex

bp-alex commented Nov 12, 2025

Copy link
Copy Markdown
Member
        env.createDbi()
            .setDbName("foo")
            .withDefaultComparator()
            .setDbiFlags(DbiFlags.MDB_CREATE)
            .open();

vs

env.open("foo", DbiFlags.MDB_CREATE)  // where MDB_CREATE is treated as a DbiFlagSet

I'm not too bothered either way so happy to go with whatever you decide.

I prefer the builder approach:

  • Explicitness: The builder shows that foo is the database name, a default comparator exists, and multiple flags are available. Compare that to env.open(..), which provides no such indication (DbiFlags.MDB_CREATE looks like a mandatory constant rather than part of a configurable set)
  • Ergonomics: When users encounter unexpected iteration order, they'll recall the comparator configuration. The builder guides them through compatible comparator selection, avoiding confusion about whether comparators exist, where they're configured, or key formatting (eg endianness, string padding, encoding etc)
  • Easier support: Builder-based code in tickets clearly shows the exact configuration and saves a communications round-trip asking for the precise Dbi configuration
  • Clean migration path: Given we are planning the next release to be 1.0.0 anyway, we can reasonably deprecate these ~10-year-old methods
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@at055612

at055612 commented Nov 13, 2025

Copy link
Copy Markdown
Collaborator Author

@benalexau Works for me. Builder it is. 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

at055612 added 17 commits November 14, 2025 15:22
@at055612
Add in test classes for deprecated methods
9a35718
@at055612
Add test coverage
8c19bf4
@at055612
Add test coverage
496e5ea
@at055612
Auto format
7bd3332
@at055612
Add more tests
06523f9
@at055612
Add test coverage
fe41338
@at055612
Add ByteBufProxyTest, refactor some test classes
38eac0d
@at055612
Add missing licences
53ac34d
@at055612
Add test assert
5ad4f0c
@at055612
Add TxnDeprecatedTest for more coverage
a0503d3
@at055612
Auto format
29d5ba2
@at055612
Add tests for XxxFlags.isSet
1312e10
@at055612
Add more test coverage
0216c92
@at055612
Change FlagSet args to be requireNonNull
8b60f29
@at055612
Add requireNonNull checks to Dbi
e53956d
@at055612
Add more coverage
654a5bc
@at055612
Add DirectBufferProxyTest
850c4e2
@at055612
at055612 merged commit db70f14 into master Nov 17, 2025
21 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@at055612 at055612

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

CursorIterable used with BACKWARD_AT_LEAST and BACKWARD_CLOSED is not returning expected ranges of results when using DUPSORT The new MDB_UNSIGNEDKEY DbiFlag should probably be the default behaviour

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@at055612 @bp-alex @github-advanced-security @stroomdev66
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.