Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 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
b46c916
Add more cursor tests to protect against future regression
stroomdev66 Oct 28, 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
916b441
Merge branch 'master' of github.com:lmdbjava/lmdbjava into more-curso…
stroomdev66 Oct 29, 2025
58dcc6e
Tidy code
at055612 Oct 29, 2025
26665ba
Fix byte order issues with compareAsIntegerKeys
at055612 Oct 29, 2025
dc0b96b
#267 Fix to establish start key when iterating backwards from a start…
stroomdev66 Oct 29, 2025
9db91a5
Merge branch 'master' of github.com:lmdbjava/lmdbjava into gh-267
stroomdev66 Oct 30, 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
7374fde
#267 Fix to establish start key when iterating backwards from a start…
stroomdev66 Nov 5, 2025
79c0df6
Merge branch 'master' of github.com:lmdbjava/lmdbjava into gh-267
stroomdev66 Nov 5, 2025
787d6d3
#267 Fix to establish start key when iterating backwards from a start…
stroomdev66 Nov 5, 2025
c289763
#267 Fix to establish start key when iterating backwards from a start…
stroomdev66 Nov 5, 2025
1acd971
Add ComparatorFactory
at055612 Nov 5, 2025
69eb5b7
#269 Initial iterator performance enhancements and testing.
stroomdev66 Nov 5, 2025
915edce
#269 Initial iterator performance enhancements and testing.
stroomdev66 Nov 5, 2025
dea7975
Merge branch 'master' into mdb_cmp
at055612 Nov 5, 2025
5a62965
Merged new comparator code
stroomdev66 Nov 5, 2025
484a772
Merged new comparator code
stroomdev66 Nov 5, 2025
ad75cb2
Fix CodeQL issues, add setMapSizeXx methods
at055612 Nov 5, 2025
77a3494
Fix failing test
at055612 Nov 5, 2025
1d46e0b
Refactor deprecated method calls
at055612 Nov 6, 2025
577062f
Fix compile issue
at055612 Nov 6, 2025
12a9679
Improve FlagSet tests
at055612 Nov 6, 2025
7a6910b
Add licence header
at055612 Nov 6, 2025
167cdad
Rename buildDbi to createDbi to be consistent with Env.create()
at055612 Nov 6, 2025
d47694e
Remove ByteUnits dep, add ByteUnit enum, add setMapSize() overload
at055612 Nov 6, 2025
fb08779
Fix compile errors
at055612 Nov 6, 2025
a82d7f2
Add more test coverage
at055612 Nov 6, 2025
534b76b
Fix codeQL issue
at055612 Nov 6, 2025
e9f9ac4
Add test coverage on FlagSet
at055612 Nov 6, 2025
b0112bb
Add tests
at055612 Nov 6, 2025
c25a7d2
Run format plugin
at055612 Nov 7, 2025
cf3a11e
Remove class separators
at055612 Nov 7, 2025
0c97cf4
Run format plugin
at055612 Nov 7, 2025
72d4e3f
Remove binaries accidentally added, fix test
at055612 Nov 7, 2025
18013fb
Merged new comparator code
stroomdev66 Nov 7, 2025
6b40d0b
Merge branch 'gh-267_plus_new_comparators' into gh-249-remove-unsigne…
at055612 Nov 7, 2025
48aa0fd
Fix javadoc warnings and class visibility, fix licence warnings
at055612 Nov 7, 2025
72b5234
Auto-format
at055612 Nov 7, 2025
dd95dea
Add error handling for parse(Int|Long)
at055612 Nov 7, 2025
b53378a
Remove unused code
at055612 Nov 7, 2025
deb1f1b
Remove unused code
at055612 Nov 7, 2025
2bfe07c
Remove unused hashCode methods
at055612 Nov 7, 2025
a84ceaa
Change CursorIterableRangeTest to do default+native modes
at055612 Nov 9, 2025
a5e4cf2
Remove separator comments
at055612 Nov 9, 2025
f8e6e07
Add more tests to CursorIterableRangeTest
at055612 Nov 9, 2025
6982aca
Remove unused test, auto format
at055612 Nov 9, 2025
6740e2b
Add tests to stop CodeQL warnings
at055612 Nov 12, 2025
0103f13
Auto format
at055612 Nov 12, 2025
4249566
Fix typo in javadoc
at055612 Nov 12, 2025
35b0a9d
Tidy code
at055612 Nov 12, 2025
9a35718
Add in test classes for deprecated methods
at055612 Nov 14, 2025
8c19bf4
Add test coverage
at055612 Nov 14, 2025
496e5ea
Add test coverage
at055612 Nov 14, 2025
7bd3332
Auto format
at055612 Nov 14, 2025
06523f9
Add more tests
at055612 Nov 14, 2025
fe41338
Add test coverage
at055612 Nov 14, 2025
38eac0d
Add ByteBufProxyTest, refactor some test classes
at055612 Nov 14, 2025
53ac34d
Add missing licences
at055612 Nov 14, 2025
5ad4f0c
Add test assert
at055612 Nov 14, 2025
a0503d3
Add TxnDeprecatedTest for more coverage
at055612 Nov 17, 2025
29d5ba2
Auto format
at055612 Nov 17, 2025
1312e10
Add tests for XxxFlags.isSet
at055612 Nov 17, 2025
0216c92
Add more test coverage
at055612 Nov 17, 2025
8b60f29
Change FlagSet args to be requireNonNull
at055612 Nov 17, 2025
e53956d
Add requireNonNull checks to Dbi
at055612 Nov 17, 2025
654a5bc
Add more coverage
at055612 Nov 17, 2025
850c4e2
Add DirectBufferProxyTest
at055612 Nov 17, 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
Prev Previous commit
Next Next commit
Run format plugin
  • Loading branch information
at055612 committed Nov 7, 2025
commit c25a7d243d2ca9103f527f784185d35ceae4c330
28 changes: 11 additions & 17 deletions src/main/java/org/lmdbjava/AbstractFlagSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

/**
* Encapsulates an immutable set of flags and the associated bit mask for the flags in the set.
*/
/** Encapsulates an immutable set of flags and the associated bit mask for the flags in the set. */
public abstract class AbstractFlagSet<T extends Enum<T> & MaskedFlag> implements FlagSet<T> {

private final Set<T> flags;
Expand Down Expand Up @@ -60,8 +58,7 @@ public Set<T> getFlags() {
@Override
public boolean isSet(final T flag) {
// Probably cheaper to compare the masks than to use EnumSet.contains()
return flag != null
&& MaskedFlag.isSet(mask, flag);
return flag != null && MaskedFlag.isSet(mask, flag);
}

/**
Expand Down Expand Up @@ -103,11 +100,10 @@ public String toString() {
return FlagSet.asString(this);
}


// --------------------------------------------------------------------------------


static abstract class AbstractSingleFlagSet<T extends Enum<T> & MaskedFlag> implements FlagSet<T> {
abstract static class AbstractSingleFlagSet<T extends Enum<T> & MaskedFlag>
Comment thread Fixed
Comment thread Fixed
implements FlagSet<T> {

private final T flag;
// Only holding this for iterator() and getFlags() so make it lazy.
Expand Down Expand Up @@ -186,10 +182,8 @@ private Set<T> initSet() {
}
}


// --------------------------------------------------------------------------------


static class AbstractEmptyFlagSet<T extends MaskedFlag> implements FlagSet<T> {
Comment thread Fixed

@Override
Expand Down Expand Up @@ -243,10 +237,8 @@ public int hashCode() {
}
}


// --------------------------------------------------------------------------------


/**
* A builder for creating a {@link AbstractFlagSet}.
*
Expand All @@ -261,10 +253,11 @@ public static class Builder<E extends Enum<E> & MaskedFlag, S extends FlagSet<E>
final Function<E, S> singletonSetConstructor;
final Supplier<S> emptySetSupplier;

protected Builder(final Class<E> type,
final Function<EnumSet<E>, S> constructor,
final Function<E, S> singletonSetConstructor,
final Supplier<S> emptySetSupplier) {
protected Builder(
final Class<E> type,
final Function<EnumSet<E>, S> constructor,
final Function<E, S> singletonSetConstructor,
final Supplier<S> emptySetSupplier) {
this.type = type;
this.enumSet = EnumSet.noneOf(type);
this.constructor = Objects.requireNonNull(constructor);
Expand All @@ -273,7 +266,8 @@ protected Builder(final Class<E> type,
}

/**
* Replaces any flags already set in the builder with the contents of the passed flags {@link Collection}
* Replaces any flags already set in the builder with the contents of the passed flags {@link
* Collection}
*
* @param flags The flags to set in the builder.
* @return this builder instance.
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/lmdbjava/BufferProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public abstract class BufferProxy<T> {
/** Offset from a pointer of the <code>MDB_val.mv_size</code> field. */
protected static final int STRUCT_FIELD_OFFSET_SIZE = 0;


/** Explicitly-defined default constructor to avoid warnings. */
protected BufferProxy() {}

Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/lmdbjava/ByteBufProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ public static int compareLexicographically(final ByteBuf o1, final ByteBuf o2) {
}

/**
* Buffer comparator specifically for 4/8 byte keys that are unsigned ints/longs,
* i.e. when using MDB_INTEGER_KEY/MDB_INTEGERDUP. Compares the buffers numerically.
* Buffer comparator specifically for 4/8 byte keys that are unsigned ints/longs, i.e. when using
* MDB_INTEGER_KEY/MDB_INTEGERDUP. Compares the buffers numerically.
*
* @param o1 left operand (required)
* @param o2 right operand (required)
Expand All @@ -101,12 +101,17 @@ public static int compareAsIntegerKeys(final ByteBuf o1, final ByteBuf o2) {
requireNonNull(o2);
// Both buffers should be same length according to LMDB API.
// From the LMDB docs for MDB_INTEGER_KEY
// numeric keys in native byte order: either unsigned int or size_t. The keys must all be of the same size.
// numeric keys in native byte order: either unsigned int or size_t. The keys must all be of the
// same size.
final int len1 = o1.readableBytes();
final int len2 = o2.readableBytes();
if (len1 != len2) {
throw new RuntimeException("Length mismatch, len1: " + len1 + ", len2: " + len2
+ ". Lengths must be identical and either 4 or 8 bytes.");
throw new RuntimeException(
"Length mismatch, len1: "
+ len1
+ ", len2: "
+ len2
+ ". Lengths must be identical and either 4 or 8 bytes.");
}
if (len1 == 8) {
final long lw;
Expand Down
36 changes: 14 additions & 22 deletions src/main/java/org/lmdbjava/ByteBufferProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ public final class ByteBufferProxy {
*/
public static final BufferProxy<ByteBuffer> PROXY_OPTIMAL;

/**
* The safe, reflective {@link ByteBuffer} proxy for this system. Guaranteed to never be null.
*/
/** The safe, reflective {@link ByteBuffer} proxy for this system. Guaranteed to never be null. */
public static final BufferProxy<ByteBuffer> PROXY_SAFE;

private static final ByteOrder NATIVE_ORDER = ByteOrder.nativeOrder();
Expand All @@ -67,8 +65,7 @@ public final class ByteBufferProxy {
PROXY_OPTIMAL = getProxyOptimal();
}

private ByteBufferProxy() {
}
private ByteBufferProxy() {}

private static BufferProxy<ByteBuffer> getProxyOptimal() {
try {
Expand All @@ -78,25 +75,19 @@ private static BufferProxy<ByteBuffer> getProxyOptimal() {
}
}

/**
* The buffer must be a direct buffer (not heap allocated).
*/
/** The buffer must be a direct buffer (not heap allocated). */
public static final class BufferMustBeDirectException extends LmdbException {

private static final long serialVersionUID = 1L;

/**
* Creates a new instance.
*/
/** Creates a new instance. */
public BufferMustBeDirectException() {
super("The buffer must be a direct buffer (not heap allocated");
}
}


// --------------------------------------------------------------------------------


/**
* Provides {@link ByteBuffer} pooling and address resolution for concrete {@link BufferProxy}
* implementations.
Expand Down Expand Up @@ -150,8 +141,8 @@ public static int compareLexicographically(final ByteBuffer o1, final ByteBuffer
}

/**
* Buffer comparator specifically for 4/8 byte keys that are unsigned ints/longs,
* i.e. when using MDB_INTEGER_KEY/MDB_INTEGERDUP. Compares the buffers numerically.
* Buffer comparator specifically for 4/8 byte keys that are unsigned ints/longs, i.e. when
* using MDB_INTEGER_KEY/MDB_INTEGERDUP. Compares the buffers numerically.
*
* @param o1 left operand (required)
* @param o2 right operand (required)
Expand All @@ -162,12 +153,17 @@ public static int compareAsIntegerKeys(final ByteBuffer o1, final ByteBuffer o2)
requireNonNull(o2);
// Both buffers should be same length according to LMDB API.
// From the LMDB docs for MDB_INTEGER_KEY
// numeric keys in native byte order: either unsigned int or size_t. The keys must all be of the same size.
// numeric keys in native byte order: either unsigned int or size_t. The keys must all be of
// the same size.
final int len1 = o1.limit();
final int len2 = o2.limit();
if (len1 != len2) {
throw new RuntimeException("Length mismatch, len1: " + len1 + ", len2: " + len2
+ ". Lengths must be identical and either 4 or 8 bytes.");
throw new RuntimeException(
"Length mismatch, len1: "
+ len1
+ ", len2: "
+ len2
+ ". Lengths must be identical and either 4 or 8 bytes.");
}
// Keys for MDB_INTEGER_KEY are written in native order so ensure we read them in that order
o1.order(NATIVE_ORDER);
Expand Down Expand Up @@ -250,10 +246,8 @@ protected byte[] getBytes(final ByteBuffer buffer) {
}
}


// --------------------------------------------------------------------------------


/**
* A proxy that uses Java reflection to modify byte buffer fields, and official JNR-FFF methods to
* manipulate native pointers.
Expand Down Expand Up @@ -298,10 +292,8 @@ protected ByteBuffer out(final ByteBuffer buffer, final Pointer ptr) {
}
}


// --------------------------------------------------------------------------------


/**
* A proxy that uses Java's "unsafe" class to directly manipulate byte buffer fields and JNR-FFF
* allocated memory pointers.
Expand Down
45 changes: 11 additions & 34 deletions src/main/java/org/lmdbjava/ByteUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,30 @@
*/
package org.lmdbjava;

/**
* Simple {@link Enum} for converting various IEC and SI byte units down a number of bytes.
*/
/** Simple {@link Enum} for converting various IEC and SI byte units down a number of bytes. */
public enum ByteUnit {

BYTES(1L),

/**
* IEC byte unit for 1024 bytes.
*/
/** IEC byte unit for 1024 bytes. */
KIBIBYTES(1024L),
/**
* IEC byte unit for 1024^2 bytes.
*/
/** IEC byte unit for 1024^2 bytes. */
MEBIBYTES(1_0485_76L),
/**
* IEC byte unit for 1024^3 bytes.
*/
/** IEC byte unit for 1024^3 bytes. */
GIBIBYTES(1_073_741_824L),
/**
* IEC byte unit for 1024^4 bytes.
*/
/** IEC byte unit for 1024^4 bytes. */
TEBIBYTES(1_099_511_627_776L),
/**
* IEC byte unit for 1024^5 bytes.
*/
/** IEC byte unit for 1024^5 bytes. */
PEBIBYTES(1_125_899_906_842_624L),

/**
* SI byte unit for 1000 bytes.
*/
/** SI byte unit for 1000 bytes. */
KILOBYTES(1_000L),
/**
* SI byte unit for 1000^2 bytes.
*/
/** SI byte unit for 1000^2 bytes. */
MEGABYTES(1_000_000L),
/**
* SI byte unit for 1000^3 bytes.
*/
/** SI byte unit for 1000^3 bytes. */
GIGABYTES(1_000_000_000L),
/**
* SI byte unit for 1000^4 bytes.
*/
/** SI byte unit for 1000^4 bytes. */
TERABYTES(1_000_000_000_000L),
/**
* SI byte unit for 1000^5 bytes.
*/
/** SI byte unit for 1000^5 bytes. */
PETABYTES(1_000_000_000_000_000L),
;

Expand Down
21 changes: 5 additions & 16 deletions src/main/java/org/lmdbjava/CopyFlagSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,20 @@ static CopyFlagSet of(final CopyFlags dbiFlag) {
}

static CopyFlagSet of(final CopyFlags... CopyFlags) {
return builder()
.setFlags(CopyFlags)
.build();
return builder().setFlags(CopyFlags).build();
}

static CopyFlagSet of(final Collection<CopyFlags> CopyFlags) {
return builder()
.setFlags(CopyFlags)
.build();
return builder().setFlags(CopyFlags).build();
}

static AbstractFlagSet.Builder<CopyFlags, CopyFlagSet> builder() {
return new AbstractFlagSet.Builder<>(
CopyFlags.class,
CopyFlagSetImpl::new,
copyFlag -> copyFlag,
() -> CopyFlagSetImpl.EMPTY);
CopyFlags.class, CopyFlagSetImpl::new, copyFlag -> copyFlag, () -> CopyFlagSetImpl.EMPTY);
}


// --------------------------------------------------------------------------------


class CopyFlagSetImpl extends AbstractFlagSet<CopyFlags> implements CopyFlagSet {

static final CopyFlagSet EMPTY = new EmptyCopyFlagSet();
Expand All @@ -65,10 +56,8 @@ private CopyFlagSetImpl(final EnumSet<CopyFlags> flags) {
}
}


// --------------------------------------------------------------------------------


class EmptyCopyFlagSet extends AbstractFlagSet.AbstractEmptyFlagSet<CopyFlags> implements CopyFlagSet {
}
class EmptyCopyFlagSet extends AbstractFlagSet.AbstractEmptyFlagSet<CopyFlags>
implements CopyFlagSet {}
}
Loading
Loading