-
Notifications
You must be signed in to change notification settings - Fork 124
gh-249 Remove MDB_UNSIGNEDKEY, let CursorIterable call mdb_cmp #250
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
5e03aec to
e598e21
Compare
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
open
txn
| /** | ||
| * @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
Iterable.iterator
| 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
Cursor.delete
| 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
| 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
Env.openDbi
| 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
Builder.open
| 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
| 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
| 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
| 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
Builder.open
|
Closing this as the changes have been moved to PR #276 |
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()andgetUnsignedComparator()have been made public so users of this library can access them.