-
Notifications
You must be signed in to change notification settings - Fork 122
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
base: master
Are you sure you want to change the base?
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 ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #250 +/- ##
============================================
- Coverage 88.25% 86.75% -1.50%
- Complexity 408 415 +7
============================================
Files 32 34 +2
Lines 1456 1563 +107
Branches 124 136 +12
============================================
+ Hits 1285 1356 +71
- Misses 101 138 +37
+ Partials 70 69 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cnt++; | ||
} | ||
} | ||
final Duration duration = Duration.between(start, Instant.now()); |
Check notice
Code scanning / CodeQL
Unread local variable Note test
populateList(); | ||
try (Txn<ByteBuffer> txn = env.txnRead(); | ||
CursorIterable<ByteBuffer> c = db.iterate(txn)) { | ||
|
Check notice
Code scanning / CodeQL
Unread local variable Note test
|
||
try (Txn<ByteBuffer> txn = env.txnRead(); | ||
CursorIterable<ByteBuffer> c = db.iterate(txn, keyRange)) { | ||
for (final CursorIterable.KeyVal<ByteBuffer> kv : c) { |
Check notice
Code scanning / CodeQL
Unread local variable Note test
public void iterate() { | ||
for (final Dbi<ByteBuffer> db : dbs) { | ||
populateList(); | ||
try (Txn<ByteBuffer> txn = env.txnRead(); |
Check notice
Code scanning / CodeQL
Unread local variable Note test
KeyRange<ByteBuffer> keyRange = KeyRange.atLeastBackward(startKeyBuf); | ||
|
||
try (Txn<ByteBuffer> txn = env.txnRead(); | ||
CursorIterable<ByteBuffer> c = db.iterate(txn, keyRange)) { |
Check notice
Code scanning / CodeQL
Unread local variable Note test
return this; | ||
} | ||
|
||
/** |
Check notice
Code scanning / CodeQL
Possible confusion of local and field Note
open
txn
dbJavaComparator = env.openDbi(DB_1, | ||
bufferProxy.getUnsignedComparator(), | ||
MDB_CREATE, | ||
MDB_INTEGERKEY); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
MDB_CREATE, | ||
MDB_INTEGERKEY); | ||
// Use LMDB comparator for start/stop keys | ||
dbLmdbComparator = env.openDbi(DB_2, MDB_CREATE, MDB_INTEGERKEY); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
dbLmdbComparator = env.openDbi(DB_2, MDB_CREATE, MDB_INTEGERKEY); | ||
// Use a java comparator for start/stop keys and as a callback comparaotr | ||
dbCallbackComparator = env.openDbi(DB_3, | ||
bufferProxy.getUnsignedComparator(), |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
bb1.get(array1); | ||
bb2.get(array2); | ||
bb1.reset(); | ||
bb2.reset(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
dbJavaComparator = | ||
env.openDbi("JavaComparator", bufferProxy.getUnsignedComparator(), MDB_CREATE); | ||
// Use LMDB comparator for start/stop keys | ||
dbLmdbComparator = env.openDbi("LmdbComparator", MDB_CREATE); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
dbLmdbComparator = env.openDbi("LmdbComparator", MDB_CREATE); | ||
// Use a java comparator for start/stop keys and as a callback comparator | ||
dbCallbackComparator = | ||
env.openDbi("CallBackComparator", bufferProxy.getUnsignedComparator(), true, MDB_CREATE); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
populateDatabase(db); | ||
|
||
// Use a java comparator for start/stop keys only | ||
dbJavaComparator = env.openDbi(DB_1, bufferProxy.getUnsignedComparator(), MDB_CREATE); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
// Use a java comparator for start/stop keys only | ||
dbJavaComparator = env.openDbi(DB_1, bufferProxy.getUnsignedComparator(), MDB_CREATE); | ||
// Use LMDB comparator for start/stop keys | ||
dbLmdbComparator = env.openDbi(DB_2, MDB_CREATE); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
Env.openDbi
// Use LMDB comparator for start/stop keys | ||
dbLmdbComparator = env.openDbi(DB_2, MDB_CREATE); | ||
// Use a java comparator for start/stop keys and as a callback comparaotr | ||
dbCallbackComparator = env.openDbi(DB_3, bufferProxy.getUnsignedComparator(), true, MDB_CREATE); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note test
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.