◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
6 changes: 2 additions & 4 deletions src/main/java/org/lmdbjava/Dbi.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ public final class Dbi<T> {
if (nativeCb) {
this.ccb =
(keyA, keyB) -> {
final T compKeyA = proxy.allocate();
final T compKeyB = proxy.allocate();
proxy.out(compKeyA, keyA);
proxy.out(compKeyB, keyB);
final int result = this.comparator.compare(compKeyA, compKeyB);
proxy.deallocate(compKeyA);
proxy.deallocate(compKeyB);
Expand Down
13 changes: 12 additions & 1 deletion src/test/java/org/lmdbjava/ComparatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ public static Object[] data() {
final ComparatorRunner string = new StringRunner();
final ComparatorRunner db = new DirectBufferRunner();
final ComparatorRunner ba = new ByteArrayRunner();
final ComparatorRunner bb = new ByteBufferRunner();
final ComparatorRunner netty = new NettyRunner();
final ComparatorRunner gub = new GuavaUnsignedBytes();
final ComparatorRunner gsb = new GuavaSignedBytes();
return new Object[] {string, db, ba, bb, netty, gub, gsb};
}

private static byte[] buffer(final int... bytes) {
Expand Down Expand Up @@ -140,6 +141,16 @@ public int compare(final byte[] o1, final byte[] o2) {
}
}

/** Tests {@link ByteBufferProxy}. */
private static final class ByteBufferRunner implements ComparatorRunner {

Expand Down
10 changes: 7 additions & 3 deletions src/test/java/org/lmdbjava/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ final class TestUtils {
private TestUtils() {}

static byte[] ba(final int value) {
final MutableDirectBuffer b = new UnsafeBuffer(new byte[4]);
b.putInt(0, value);
return b.byteArray();
}

static ByteBuffer bb(final int value) {
Expand Down
Toggle all file notes Toggle all file annotations