Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit838a8a0

Browse files
authored
Fix build on aarch64 (e.g. Apple Silicon) (lmdbjava#218)
* Increase map size to multiple of larger page sizeMost architectures such as x86 and x86-64 use 4KiB, while aarch64 systems can use 4, 16 or 64KiB. Apple Silicon machines currently have 16KiB page sizes. The LMDB documentation states that map size should be a multiple of the page size, so a 100KiB default map size for tests fails for systems with a page size that is not 4 KiB.This commit simply increases the map size for tests. Of course, this applies only to these tests, as in production, users can choose the appropriate map size for their requirements and system architecture. It is not straightforward to determine architecture page size at runtime. Otherwise, it might be more appropriate to dynamically determine a minimum map size.* Tweak test of page sizeThe options for determining architecture page size are a) environment variables, b) unsafe and undocumented JDK internals or c) looking to get answer using FFI. Given this test is asking checking the statistics returned by LMDB, on balance it is reasonable to simply validate we're getting a multiple of 4096 in the statistics report.* Fix test for cut-off given large map sizes
1 parent533ae0f commit838a8a0

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

‎src/test/java/org/lmdbjava/CursorIterableTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public void atMostTest() {
126126
publicvoidbefore()throwsIOException {
127127
finalFilepath =tmp.newFile();
128128
env =create()
129-
.setMapSize(KIBIBYTES.toBytes(100))
129+
.setMapSize(KIBIBYTES.toBytes(256))
130130
.setMaxReaders(1)
131131
.setMaxDbs(1)
132132
.open(path,POSIX_MODE,MDB_NOSUBDIR);

‎src/test/java/org/lmdbjava/DbiTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public void stats() {
460460
assertThat(stat.entries,is(3L));
461461
assertThat(stat.leafPages,is(1L));
462462
assertThat(stat.overflowPages,is(0L));
463-
assertThat(stat.pageSize,is(4_096));
463+
assertThat(stat.pageSize %4_096,is(0));
464464
}
465465

466466
@Test(expected =MapFullException.class)

‎src/test/java/org/lmdbjava/EnvTest.java‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
packageorg.lmdbjava;
2222

23+
importstaticcom.jakewharton.byteunits.BinaryByteUnit.KIBIBYTES;
2324
importstaticcom.jakewharton.byteunits.BinaryByteUnit.MEBIBYTES;
2425
importstaticjava.nio.ByteBuffer.allocateDirect;
2526
importstaticorg.hamcrest.CoreMatchers.containsString;
@@ -338,15 +339,15 @@ public void setMapSize() throws IOException {
338339
finalRandomrnd =newRandom();
339340
try (Env<ByteBuffer>env =create()
340341
.setMaxReaders(1)
341-
.setMapSize(50_000)
342+
.setMapSize(KIBIBYTES.toBytes(256))
342343
.setMaxDbs(1)
343344
.open(path)) {
344345
finalDbi<ByteBuffer>db =env.openDbi(DB_1,MDB_CREATE);
345346

346347
db.put(bb(1),bb(42));
347348
booleanmapFullExThrown =false;
348349
try {
349-
for (inti =0;i <30;i++) {
350+
for (inti =0;i <70;i++) {
350351
rnd.nextBytes(k);
351352
key.clear();
352353
key.put(k).flip();
@@ -358,15 +359,15 @@ public void setMapSize() throws IOException {
358359
}
359360
assertThat(mapFullExThrown,is(true));
360361

361-
env.setMapSize(500_000);
362+
env.setMapSize(KIBIBYTES.toBytes(512));
362363

363364
try (Txn<ByteBuffer>roTxn =env.txnRead()) {
364365
assertThat(db.get(roTxn,bb(1)).getInt(),is(42));
365366
}
366367

367368
mapFullExThrown =false;
368369
try {
369-
for (inti =0;i <30;i++) {
370+
for (inti =0;i <70;i++) {
370371
rnd.nextBytes(k);
371372
key.clear();
372373
key.put(k).flip();
@@ -393,7 +394,7 @@ public void stats() throws IOException {
393394
assertThat(stat.entries,is(0L));
394395
assertThat(stat.leafPages,is(0L));
395396
assertThat(stat.overflowPages,is(0L));
396-
assertThat(stat.pageSize,is(4_096));
397+
assertThat(stat.pageSize %4_096,is(0));
397398
assertThat(stat.toString(),containsString("pageSize="));
398399
}
399400
}

‎src/test/java/org/lmdbjava/TxnTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void after() {
8484
publicvoidbefore()throwsIOException {
8585
path =tmp.newFile();
8686
env =create()
87-
.setMapSize(KIBIBYTES.toBytes(100))
87+
.setMapSize(KIBIBYTES.toBytes(256))
8888
.setMaxReaders(1)
8989
.setMaxDbs(2)
9090
.open(path,POSIX_MODE,MDB_NOSUBDIR);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp