FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-249 Remove MDB_UNSIGNEDKEY, let CursorIterable call mdb_cmp by at055612 · Pull Request #250 · lmdbjava/lmdbjava · GitHub

gh-249 Remove MDB_UNSIGNEDKEY, let CursorIterable call mdb_cmp - #250

Closed
at055612 wants to merge 25 commits into
lmdbjava:masterfrom
at055612:mdb_cmp
Closed

gh-249 Remove MDB_UNSIGNEDKEY, let CursorIterable call mdb_cmp#250
at055612 wants to merge 25 commits into
lmdbjava:masterfrom
at055612:mdb_cmp

Conversation

at055612 commented Mar 6, 2025

Copy link
Copy Markdown
Collaborator

Fixes #249

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.

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.

codecov Bot commented Mar 6, 2025
edited
Loading

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.06452% with 167 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.06%. Comparing base (65df2ee) to head (dea7975).

Files with missing lines Patch % Lines
src/main/java/org/lmdbjava/AbstractFlagSet.java 72.61% 13 Missing and 10 partials ⚠️
src/main/java/org/lmdbjava/Env.java 63.79% 17 Missing and 4 partials ⚠️
src/main/java/org/lmdbjava/DbiBuilder.java 77.01% 13 Missing and 7 partials ⚠️
src/main/java/org/lmdbjava/Cursor.java 57.57% 8 Missing and 6 partials ⚠️
src/main/java/org/lmdbjava/FlagSet.java 63.33% 6 Missing and 5 partials ⚠️
src/main/java/org/lmdbjava/ByteBufProxy.java 62.96% 6 Missing and 4 partials ⚠️
src/main/java/org/lmdbjava/Dbi.java 72.22% 8 Missing and 2 partials ⚠️
src/main/java/org/lmdbjava/CopyFlagSet.java 50.00% 9 Missing ⚠️
src/main/java/org/lmdbjava/TxnFlagSet.java 62.50% 6 Missing ⚠️
src/main/java/org/lmdbjava/Key.java 73.68% 4 Missing and 1 partial ⚠️
... and 13 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #250      +/-   ##
============================================
- Coverage     89.06%   85.06%   -4.01%     
- Complexity      413      507      +94     
============================================
  Files            32       41       +9     
  Lines          1482     1962     +480     
  Branches        125      180      +55     
============================================
+ Hits           1320     1669     +349     
- Misses           92      177      +85     
- Partials         70      116      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cnt++;
}
}
final Duration duration = Duration.between(start, Instant.now());

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'KeyVal kv' is never read.
bb1.get(array1);
bb2.get(array2);
bb1.reset();
bb2.reset();

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking Env.openDbi should be avoided because it has been deprecated.
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 now
Env#txn(Txn)
Env#txn(Txn, TxnFlags)
Env#txn(Txn, TxnFlagSet)
Also improve javadoc and refactor some tests to use DbiBuilder.

Some tests are failing.
if (txn != null) {
return open(txn, dbiBuilder);
} else {
try (final Txn<T> txn = getTxn(dbiBuilder)) {

Check notice

Code scanning / CodeQL

Possible confusion of local and field Note

Confusing name: method open also refers to field txn (without qualifying it with 'this').
at055612 self-assigned this Oct 28, 2025
/**
* @return The {@link Iterator} (in no particular order) for the flags in this {@link FlagSet}.
*/
default Iterator<T> iterator() {

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides Iterable.iterator ; it is advisable to add an Override annotation.
try (Txn<ByteBuffer> txn = env.txnWrite();
final Cursor<ByteBuffer> cursor = db.openCursor(txn)) {
while (cursor.next()) {
cursor.delete();

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking Cursor.delete should be avoided because it has been deprecated.
final long[] values = random.longs(5_000_000).toArray();

Instant time = Instant.now();
int x = 0;

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'int x' is never read.
bb2.reset();
return guava.compare(array1, array2);
};
final Dbi<ByteBuffer> guavaDbi = env.openDbi(DB_1, comparator, MDB_CREATE);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking Env.openDbi should be avoided because it has been deprecated.
Comment on lines +127 to +131
create(bufferProxy)
.setMapSize(KIBIBYTES.toBytes(256))
.setMaxReaders(1)
.setMaxDbs(3)
.open(file.toFile(), POSIX_MODE, MDB_NOSUBDIR);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking Builder.open should be avoided because it has been deprecated.
try (Txn<ByteBuffer> txn = env.txnRead()) {
try (CursorIterable<ByteBuffer> iterable = db.iterate(txn)) {
for (KeyVal<ByteBuffer> keyVal : iterable) {
final String val = getString(keyVal.val());

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'String val' is never read.
try (CursorIterable<ByteBuffer> iterable = db.iterate(txn)) {
for (KeyVal<ByteBuffer> keyVal : iterable) {
final String val = getString(keyVal.val());
final long key = getNativeLong(keyVal.key());

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'long key' is never read.
for (KeyVal<ByteBuffer> keyVal : iterable) {
final String val = getString(keyVal.val());
final long key = getNativeLong(keyVal.key());
final int remaining = keyVal.key().remaining();

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'int remaining' is never read.
Comment on lines +59 to +63
create(bufferProxy)
.setMapSize(GIBIBYTES.toBytes(1))
.setMaxReaders(1)
.setMaxDbs(3)
.open(file.toFile(), POSIX_MODE, MDB_NOSUBDIR);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note test

Invoking Builder.open should be avoided because it has been deprecated.

at055612 commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator Author

Closing this as the changes have been moved to PR #276

at055612 closed this Nov 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The new MDB_UNSIGNEDKEY DbiFlag should probably be the default behaviour

2 participants


Back | FazBrowse Home | New Git URL