Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
480e984
gh-249 Remove MDB_UNSIGNEDKEY, let CursorIterable call mdb_cmp
at055612 Mar 6, 2025
46f8d08
gh-249 Remove non-J8 features, use indent size 2
at055612 Mar 6, 2025
f92012e
gh-249 Fix indents
at055612 Mar 6, 2025
e1756d6
gh-249 Tidy code and refactor RangeComparator impls
at055612 Mar 6, 2025
9509f6b
gh-249 Remove commented code
at055612 Mar 6, 2025
67e2df1
gh-249 Add CursorIterableIntegerKeyTest
at055612 Mar 7, 2025
620a89f
gh-249 Remove MaskedFlag.isPropagatedToLmdb, add DbiBuilder WIP
at055612 Jun 5, 2025
75d87d0
Merge branch 'master' into mdb_cmp
at055612 Oct 26, 2025
47b4c4f
Merge branch 'master' into mdb_cmp
at055612 Oct 26, 2025
bfbf223
Add FlagSet, DbiFlagSet, PutFlagSet
at055612 Oct 27, 2025
0f66aaf
Rename FlagSet to AbstractFlagSet
at055612 Oct 27, 2025
aa000a1
Add remaining FlagSet impls
at055612 Oct 27, 2025
667dab3
Fix Javadoc
at055612 Oct 27, 2025
0234d32
Replace get(Uns|S)ignedComparator with getComparator(DbiFlagSet)
at055612 Oct 28, 2025
ef0c852
Add missing txn commit in DbiBuilder
at055612 Oct 28, 2025
1b3f94d
Change CursorIterableTest to use Parameterized
at055612 Oct 28, 2025
c0bbe73
Deprecate methods using varargs flags
at055612 Oct 28, 2025
4fd89ff
Add int key compare method to (Direct|Byte)BufferProxy
at055612 Oct 29, 2025
58dcc6e
Tidy code
at055612 Oct 29, 2025
26665ba
Fix byte order issues with compareAsIntegerKeys
at055612 Oct 29, 2025
c427801
Add/refactor tests
at055612 Nov 4, 2025
f606e7e
Merge branch 'master' into mdb_cmp
at055612 Nov 4, 2025
e2be6bf
Add integer key comparator tests
at055612 Nov 5, 2025
1acd971
Add ComparatorFactory
at055612 Nov 5, 2025
dea7975
Merge branch 'master' into mdb_cmp
at055612 Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions src/main/java/org/lmdbjava/BufferProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
package org.lmdbjava;

import static java.lang.Long.BYTES;
import static org.lmdbjava.DbiFlags.MDB_INTEGERKEY;
import static org.lmdbjava.DbiFlags.MDB_UNSIGNEDKEY;
import static org.lmdbjava.MaskedFlag.isSet;
import static org.lmdbjava.MaskedFlag.mask;

import java.util.Comparator;
import jnr.ffi.Pointer;
Expand Down Expand Up @@ -70,36 +66,25 @@ protected BufferProxy() {}
*/
protected abstract byte[] getBytes(T buffer);

/**
* Get a suitable default {@link Comparator} given the provided flags.
*
* <p>The provided comparator must strictly match the lexicographical order of keys in the native
* LMDB database.
*
* @param flags for the database
* @return a comparator that can be used (never null)
*/
protected Comparator<T> getComparator(DbiFlags... flags) {
final int intFlag = mask(flags);

return isSet(intFlag, MDB_INTEGERKEY) || isSet(intFlag, MDB_UNSIGNEDKEY)
? getUnsignedComparator()
: getSignedComparator();
}

/**
* Get a suitable default {@link Comparator} to compare numeric key values as signed.
*
* <p>
* Note: LMDB's default comparator is unsigned so if this is used only for the {@link CursorIterable}
* start/stop key comparisons then its behaviour will differ from the iteration order. Use
* with caution.
* </p>
*
* @return a comparator that can be used (never null)
*/
protected abstract Comparator<T> getSignedComparator();
public abstract Comparator<T> getSignedComparator();

/**
* Get a suitable default {@link Comparator} to compare numeric key values as unsigned.
*
* @return a comparator that can be used (never null)
*/
protected abstract Comparator<T> getUnsignedComparator();
public abstract Comparator<T> getUnsignedComparator();

/**
* Called when the <code>MDB_val</code> should be set to reflect the passed buffer. This buffer
Expand Down Expand Up @@ -140,4 +125,13 @@ protected Comparator<T> getComparator(DbiFlags... flags) {
final KeyVal<T> keyVal() {
return new KeyVal<>(this);
}

/**
* Create a new {@link Key} to hold pointers for this buffer proxy.
*
* @return a non-null key holder
*/
final Key<T> key() {
return new Key<>(this);
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/lmdbjava/ByteArrayProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ protected byte[] getBytes(final byte[] buffer) {
}

@Override
protected Comparator<byte[]> getSignedComparator() {
public Comparator<byte[]> getSignedComparator() {
return signedComparator;
}

@Override
protected Comparator<byte[]> getUnsignedComparator() {
public Comparator<byte[]> getUnsignedComparator() {
return unsignedComparator;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/lmdbjava/ByteBufProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ protected ByteBuf allocate() {
}

@Override
protected Comparator<ByteBuf> getSignedComparator() {
public Comparator<ByteBuf> getSignedComparator() {
return comparator;
}

@Override
protected Comparator<ByteBuf> getUnsignedComparator() {
public Comparator<ByteBuf> getUnsignedComparator() {
return comparator;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/lmdbjava/ByteBufferProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ protected final ByteBuffer allocate() {
}

@Override
protected Comparator<ByteBuffer> getSignedComparator() {
public Comparator<ByteBuffer> getSignedComparator() {
return signedComparator;
}

@Override
protected Comparator<ByteBuffer> getUnsignedComparator() {
public Comparator<ByteBuffer> getUnsignedComparator() {
return unsignedComparator;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/lmdbjava/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ public T key() {
return kv.key();
}

KeyVal<T> keyVal() {
return kv;
}

/**
* Position at last key/data item.
*
Expand Down
Loading