Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 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
d6e0ca1
#269 Initial iterator performance enhancements and testing.
stroomdev66 Nov 4, 2025
71c53e7
Merge branch 'master' of github.com:lmdbjava/lmdbjava into iterator-p…
stroomdev66 Nov 4, 2025
d56b0d4
#269 Initial iterator performance enhancements and testing.
stroomdev66 Nov 5, 2025
8cecdd6
#269 Initial iterator performance enhancements and testing.
stroomdev66 Nov 5, 2025
e2be6bf
Add integer key comparator tests
at055612 Nov 5, 2025
aecdf51
#269 Initial iterator performance enhancements and testing.
stroomdev66 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
a3b9dea
Merge branch 'gh-267' of github.com:lmdbjava/lmdbjava into iterator-p…
stroomdev66 Nov 5, 2025
a7a41f4
#269 Initial iterator performance enhancements and testing.
stroomdev66 Nov 5, 2025
f23de09
#269 Initial iterator performance enhancements and testing.
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
7d04445
#269 Initial iterator performance enhancements and testing.
stroomdev66 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
6966a33
Merge branch 'gh-249-remove-unsignedkey' of github.com:lmdbjava/lmdbj…
stroomdev66 Nov 10, 2025
9541da3
Merge branch 'gh-249-remove-unsignedkey' of github.com:lmdbjava/lmdbj…
stroomdev66 Nov 10, 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
Merge branch 'master' into mdb_cmp
  • Loading branch information
at055612 committed Nov 4, 2025
commit f606e7ee85bd5511a58e172940225a93a20d4bb3
3 changes: 3 additions & 0 deletions src/main/java/org/lmdbjava/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
*/
public List<byte[]> getDbiNames() {
final List<byte[]> result = new ArrayList<>();
final Dbi<T> names = openDbi((byte[]) null);

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
Env.openDbi
should be avoided because it has been deprecated.
try (Txn<T> txn = txnRead();
Cursor<T> cursor = names.openCursor(txn)) {
if (!cursor.first()) {
Expand Down Expand Up @@ -508,7 +508,7 @@
return new Txn<>(this, parent, proxy, flag);
}

/**

Check notice

Code scanning / CodeQL

Confusing overloading of methods Note

Method Env.txn(..) could be confused with overloaded method
txn
, since dispatch depends on static types.
* Obtain a transaction with the requested parent and flags.
*
* @param parent parent transaction (may be null if no parent)
Expand Down Expand Up @@ -644,6 +644,8 @@
* @return an environment ready for use
*/
public Env<T> open(final File path, final int mode, final EnvFlags... flags) {
// TODO Use EnvFlagSet and deprecate
// TODO Make setUnixPermissions(int) method on builder.
requireNonNull(path);
if (opened) {
throw new AlreadyOpenException();
Expand Down Expand Up @@ -675,6 +677,7 @@
* @return an environment ready for use
*/
public Env<T> open(final File path, final EnvFlags... flags) {
// TODO make constant
return open(path, 0664, flags);
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/lmdbjava/MaskedFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,20 @@ static <M extends MaskedFlag> int mask(final M... flags) {
}
}

/**
* Combine the two masks into a single mask value, i.e. when combining two {@link FlagSet}s.
*/
static <M extends MaskedFlag> int mask(final int mask1, final int mask2) {
return mask1 | mask2;
}

/**
* Fetch the integer mask for the presented flags.
*
* @param <M> flag type
* @param flags to mask (null or empty returns zero)
* @return the integer mask for use in C
*/
static <M extends MaskedFlag> int mask(final Collection<M> flags) {
if (flags == null || flags.isEmpty()) {
return EMPTY_MASK;
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/org/lmdbjava/ReferenceUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ private ReferenceUtil() {}
* Vladimir Ivanov on reachabilityFence implementation</a>
*/
public static void reachabilityFence0(final Object ref) {
if (ref != null) {
//noinspection EmptySynchronizedStatement
synchronized (ref) {
// Empty synchronized is ok: https://stackoverflow.com/a/31933260/1151521
}
}
// Empty method body is intentional - the method call itself at bytecode level
// extends the object's live range per HotSpot JIT behavior
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
47 changes: 25 additions & 22 deletions src/test/java/org/lmdbjava/ByteBufferProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@
import java.util.Set;
import jnr.ffi.Pointer;
import jnr.ffi.provider.MemoryManager;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.lmdbjava.ByteBufferProxy.BufferMustBeDirectException;
import org.lmdbjava.Env.ReadersFullException;

Expand All @@ -61,20 +59,23 @@

static final MemoryManager MEM_MGR = RUNTIME.getMemoryManager();

@Rule
public final TemporaryFolder tmp = new TemporaryFolder();

@Test(expected = BufferMustBeDirectException.class)
public void buffersMustBeDirect() throws IOException {
final File path = tmp.newFolder();
try (Env<ByteBuffer> env = create().setMaxReaders(1).open(path)) {
final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
final ByteBuffer key = allocate(100);
key.putInt(1).flip();
final ByteBuffer val = allocate(100);
val.putInt(1).flip();
db.put(key, val); // error
}
@Test
void buffersMustBeDirect() {
assertThatThrownBy(
() -> {
FileUtil.useTempDir(
dir -> {
try (Env<ByteBuffer> env = create().setMaxReaders(1).open(dir.toFile())) {
final Dbi<ByteBuffer> db = env.openDbi(DB_1, 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.
final ByteBuffer key = allocate(100);
key.putInt(1).flip();
final ByteBuffer val = allocate(100);
val.putInt(1).flip();
db.put(key, val); // error
}
});
})
.isInstanceOf(BufferMustBeDirectException.class);
}

@Test
Expand All @@ -98,9 +99,9 @@
@Test
void fieldNeverFound() {
assertThatThrownBy(
() -> {
findField(Exception.class, "notARealField");
})
() -> {
findField(Exception.class, "notARealField");
})
.isInstanceOf(LmdbException.class);
}

Expand Down Expand Up @@ -157,7 +158,7 @@
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.
for (int rounds = 0; rounds < 100; rounds++) {
for (int i = 1; i < values.length; i++) {
buffer1.order(ByteOrder.nativeOrder())
Expand Down Expand Up @@ -234,7 +235,9 @@
});

if (uniqueResults.size() != 1) {
Assert.fail("Comparator mismatch for values: " + val1 + " and " + val2 + ". Results: " + results);
Assertions.fail("Comparator mismatch for values: "
+ val1 + " and "
+ val2 + ". Results: " + results);
}
}
}
Expand Down
64 changes: 20 additions & 44 deletions src/test/java/org/lmdbjava/CopyFlagSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,44 @@
*/
package org.lmdbjava;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.assertj.core.api.Assertions.assertThat;

import java.util.Collections;
import java.util.HashSet;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CopyFlagSetTest {

@Test
public void testEmpty() {
final CopyFlagSet copyFlagSet = CopyFlagSet.empty();
assertThat(
copyFlagSet.getMask(),
is(0));
assertThat(
copyFlagSet.size(),
is(0));
assertThat(
copyFlagSet.isEmpty(),
is(true));
assertThat(
copyFlagSet.isSet(CopyFlags.MDB_CP_COMPACT),
is(false));
assertThat(copyFlagSet.getMask()).isEqualTo(0);
assertThat(copyFlagSet.size()).isEqualTo(0);
assertThat(copyFlagSet.isEmpty()).isEqualTo(true);
assertThat(copyFlagSet.isSet(CopyFlags.MDB_CP_COMPACT)).isEqualTo(false);
final CopyFlagSet copyFlagSet2 = CopyFlagSet.builder()
.build();
assertThat(copyFlagSet, is(copyFlagSet2));
assertThat(copyFlagSet, not(CopyFlagSet.of(CopyFlags.MDB_CP_COMPACT)));
assertThat(copyFlagSet, not(CopyFlagSet.builder()
assertThat(copyFlagSet).isEqualTo(copyFlagSet2);
assertThat(copyFlagSet).isNotEqualTo(CopyFlagSet.of(CopyFlags.MDB_CP_COMPACT));
assertThat(copyFlagSet).isNotEqualTo(CopyFlagSet.builder()
.setFlag(CopyFlags.MDB_CP_COMPACT)
.build()));
.build());
}

@Test
public void testOf() {
final CopyFlags copyFlag = CopyFlags.MDB_CP_COMPACT;
final CopyFlagSet copyFlagSet = CopyFlagSet.of(copyFlag);
assertThat(
copyFlagSet.getMask(),
is(MaskedFlag.mask(copyFlag)));
assertThat(
copyFlagSet.size(),
is(1));
assertThat(copyFlagSet.getMask()).isEqualTo(MaskedFlag.mask(copyFlag));
assertThat(copyFlagSet.size()).isEqualTo(1);
for (CopyFlags flag : copyFlagSet) {
assertThat(
copyFlagSet.isSet(flag),
is(true));
assertThat(copyFlagSet.isSet(flag)).isEqualTo(true);
}

final CopyFlagSet copyFlagSet2 = CopyFlagSet.builder()
.setFlag(copyFlag)
.build();
assertThat(copyFlagSet, is(copyFlagSet2));
assertThat(copyFlagSet).isEqualTo(copyFlagSet2);
}

@Test
Expand All @@ -77,27 +61,19 @@ public void testBuilder() {
final CopyFlagSet copyFlagSet = CopyFlagSet.builder()
.setFlag(copyFlag1)
.build();
assertThat(
copyFlagSet.getMask(),
is(MaskedFlag.mask(copyFlag1)));
assertThat(
copyFlagSet.size(),
is(1));
assertThat(
copyFlagSet.isSet(CopyFlags.MDB_CP_COMPACT),
is(true));
assertThat(copyFlagSet.getMask()).isEqualTo(MaskedFlag.mask(copyFlag1));
assertThat(copyFlagSet.size()).isEqualTo(1);
assertThat(copyFlagSet.isSet(CopyFlags.MDB_CP_COMPACT)).isEqualTo(true);
for (CopyFlags flag : copyFlagSet) {
assertThat(
copyFlagSet.isSet(flag),
is(true));
assertThat(copyFlagSet.isSet(flag)).isEqualTo(true);
}
final CopyFlagSet copyFlagSet2 = CopyFlagSet.builder()
.withFlags(copyFlag1)
.build();
final CopyFlagSet copyFlagSet3 = CopyFlagSet.builder()
.withFlags(new HashSet<>(Collections.singletonList(copyFlag1)))
.build();
assertThat(copyFlagSet, is(copyFlagSet2));
assertThat(copyFlagSet, is(copyFlagSet3));
assertThat(copyFlagSet).isEqualTo(copyFlagSet2);
assertThat(copyFlagSet).isEqualTo(copyFlagSet3);
}
}
Loading
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.