- Notifications
You must be signed in to change notification settings - Fork124
Remove MDB_UNSIGNEDKEY, add a builder for Dbi, add MDB_INTEGERKEY comparators#276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
There are now essentially three ways of configuring comparatorswhen creating a Dbi.**null comparator**LMDB will use its own comparator & CursorIterable will call downto mdb_cmp for comparisons between the current cursor key and therange start/stop key.**provided comparator**LMDB will use its own comparator & CursorIterable will use theprovided comparator for comparisons between the current cursorkey 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 forcomparisons between the current cursor key and the rangestart/stop key.The methods `getSignedComparator()` and `getUnsignedComparator()`have been made public so users of this library can access them.
Refactor DbiBuilder and Dbi ctor to use DbiFlagSet.
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 nowEnv#txn(Txn)Env#txn(Txn, TxnFlags)Env#txn(Txn, TxnFlagSet)
Also improve javadoc and refactor some tests to use DbiBuilder.Some tests are failing.
… key using DUPSORT
… key using DUPSORT
… key using DUPSORT
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
benalexau commentedNov 7, 2025
Thanks@at055612 for this extensive PR. Just looking over it, would you please remove formatting changes to files where they are not otherwise required, such as extra lines, spaces and hyphen-based section separators. Also the I feel we should defer this PR until 0.10.0:
I have added the Does this seem reasonable to you? |
at055612 commentedNov 7, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@benalexau, releasing this in 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. 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. publicDbi<T>openDbi(finalbyte[]name,finalDbiFlagSetdbiFlagSet) { }publicDbi<T>openDbi(finalStringname,finalDbiFlagSetdbiFlagSet) { } 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 publicBuilder<T>setMapSize(finallongmapSize,finalByteUnitbyteUnit) { } |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classCopyFlagSetTestextendsAbstractFlagSetTest<CopyFlags,CopyFlagSet> { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces Note test
Show autofix suggestionHide autofix suggestion
Copilot Autofix
AI about 16 hours ago
The best way to fix the problem without changing the existing functionality is to ensure the class is actually used. Since this is a test class and is likely meant to be discovered and run by a test framework, we should make the classpublic, following standard Java testing conventions. This way, test frameworks like JUnit can find and run the tests inside it, provided the right annotations and structure are in place. The change is minimal and simply involves adding thepublic access modifier to the class declaration insrc/test/java/org/lmdbjava/CopyFlagSetTest.java.
| @@ -20,7 +20,7 @@ | ||
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classCopyFlagSetTestextendsAbstractFlagSetTest<CopyFlags,CopyFlagSet> { | ||
| publicclassCopyFlagSetTestextendsAbstractFlagSetTest<CopyFlags,CopyFlagSet> { | ||
| @Override | ||
| List<CopyFlags>getAllFlags() { |
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classDbiFlagSetTestextendsAbstractFlagSetTest<DbiFlags,DbiFlagSet> { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces Note test
Show autofix suggestionHide autofix suggestion
Copilot Autofix
AI about 16 hours ago
To fix the problem, you should remove the unused class. Specifically:
- Delete the entire
DbiFlagSetTestclass fromsrc/test/java/org/lmdbjava/DbiFlagSetTest.java, including all its methods and class definition. - Ensure that only the code for this class is removed, and that any license headers or package/import statements not used elsewhere are also removed if the file becomes empty.
- If this file contains only this class, the whole file should be deleted or left empty.
| @@ -1,59 +1 @@ | ||
| /* | ||
| *Copyright ©2016-2025TheLmdbJavaOpenSourceProject | ||
| * | ||
| *LicensedundertheApacheLicense,Version2.0 (the "License"); | ||
| *youmaynotusethisfileexceptincompliancewiththeLicense. | ||
| *YoumayobtainacopyoftheLicenseat | ||
| * | ||
| *http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| *Unlessrequiredbyapplicablelaworagreedtoinwriting,software | ||
| *distributedundertheLicenseisdistributedonan"AS IS"BASIS, | ||
| *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. | ||
| *SeetheLicenseforthespecificlanguagegoverningpermissionsand | ||
| *limitationsundertheLicense. | ||
| */ | ||
| packageorg.lmdbjava; | ||
| importjava.util.Arrays; | ||
| importjava.util.Collection; | ||
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classDbiFlagSetTestextendsAbstractFlagSetTest<DbiFlags,DbiFlagSet> { | ||
| @Override | ||
| List<DbiFlags>getAllFlags() { | ||
| returnArrays.stream(DbiFlags.values()).collect(Collectors.toList()); | ||
| } | ||
| @Override | ||
| DbiFlagSetgetEmptyFlagSet() { | ||
| returnDbiFlagSet.empty(); | ||
| } | ||
| @Override | ||
| AbstractFlagSet.Builder<DbiFlags,DbiFlagSet>getBuilder() { | ||
| returnDbiFlagSet.builder(); | ||
| } | ||
| @Override | ||
| Class<DbiFlags>getFlagType() { | ||
| returnDbiFlags.class; | ||
| } | ||
| @Override | ||
| DbiFlagSetgetFlagSet(Collection<DbiFlags>flags) { | ||
| returnDbiFlagSet.of(flags); | ||
| } | ||
| @Override | ||
| DbiFlagSetgetFlagSet(DbiFlags[]flags) { | ||
| returnDbiFlagSet.of(flags); | ||
| } | ||
| @Override | ||
| DbiFlagSetgetFlagSet(DbiFlagsflag) { | ||
| returnDbiFlagSet.of(flag); | ||
| } | ||
| } |
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classEnvFlagSetTestextendsAbstractFlagSetTest<EnvFlags,EnvFlagSet> { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces Note test
Show autofix suggestionHide autofix suggestion
Copilot Autofix
AI about 16 hours ago
To fix this issue, delete theEnvFlagSetTest class entirely fromsrc/test/java/org/lmdbjava/EnvFlagSetTest.java as it is unused and serves no purpose, thus removing unnecessary clutter from the codebase. Specifically, remove all lines in the file containing the definition of and code for theEnvFlagSetTest class, which comprises the only substantial code in this file. No additional methods, imports, or changes elsewhere are needed.
| @@ -1,59 +1 @@ | ||
| /* | ||
| *Copyright ©2016-2025TheLmdbJavaOpenSourceProject | ||
| * | ||
| *LicensedundertheApacheLicense,Version2.0 (the "License"); | ||
| *youmaynotusethisfileexceptincompliancewiththeLicense. | ||
| *YoumayobtainacopyoftheLicenseat | ||
| * | ||
| *http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| *Unlessrequiredbyapplicablelaworagreedtoinwriting,software | ||
| *distributedundertheLicenseisdistributedonan"AS IS"BASIS, | ||
| *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. | ||
| *SeetheLicenseforthespecificlanguagegoverningpermissionsand | ||
| *limitationsundertheLicense. | ||
| */ | ||
| packageorg.lmdbjava; | ||
| importjava.util.Arrays; | ||
| importjava.util.Collection; | ||
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classEnvFlagSetTestextendsAbstractFlagSetTest<EnvFlags,EnvFlagSet> { | ||
| @Override | ||
| List<EnvFlags>getAllFlags() { | ||
| returnArrays.stream(EnvFlags.values()).collect(Collectors.toList()); | ||
| } | ||
| @Override | ||
| EnvFlagSetgetEmptyFlagSet() { | ||
| returnEnvFlagSet.empty(); | ||
| } | ||
| @Override | ||
| AbstractFlagSet.Builder<EnvFlags,EnvFlagSet>getBuilder() { | ||
| returnEnvFlagSet.builder(); | ||
| } | ||
| @Override | ||
| EnvFlagSetgetFlagSet(Collection<EnvFlags>flags) { | ||
| returnEnvFlagSet.of(flags); | ||
| } | ||
| @Override | ||
| EnvFlagSetgetFlagSet(EnvFlags[]flags) { | ||
| returnEnvFlagSet.of(flags); | ||
| } | ||
| @Override | ||
| EnvFlagSetgetFlagSet(EnvFlagsflag) { | ||
| returnEnvFlagSet.of(flag); | ||
| } | ||
| @Override | ||
| Class<EnvFlags>getFlagType() { | ||
| returnEnvFlags.class; | ||
| } | ||
| } |
| importjava.util.List; | ||
| importjava.util.stream.Collectors; | ||
| classTxnFlagSetTestextendsAbstractFlagSetTest<TxnFlags,TxnFlagSet> { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces Note test
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persistscontact support.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Fixes#249
Fixes#267
Two fixes in one PR as both need each other.