Skip to content

Commit 4e2d938

Browse files
committed
Automatic formatting only
1 parent 4693eb8 commit 4e2d938

File tree

4 files changed

+61
-61
lines changed

4 files changed

+61
-61
lines changed

src/main/java/org/lmdbjava/Env.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ public List<byte[]> getDbiNames() {
187187
return result;
188188
}
189189

190+
/**
191+
* Set the size of the data memory map.
192+
*
193+
* @param mapSize the new size, in bytes
194+
*/
195+
public void setMapSize(final long mapSize) {
196+
checkRc(LIB.mdb_env_set_mapsize(ptr, mapSize));
197+
}
198+
190199
/**
191200
* Get the maximum size of keys and MDB_DUPSORT data we can write.
192201
*
@@ -383,15 +392,6 @@ Pointer pointer() {
383392
return ptr;
384393
}
385394

386-
/**
387-
* Set the size of the data memory map.
388-
*
389-
* @param mapSize the new size, in bytes
390-
*/
391-
public void setMapSize(final long mapSize) {
392-
checkRc(LIB.mdb_env_set_mapsize(ptr, mapSize));
393-
}
394-
395395
/**
396396
* Object has already been closed and the operation is therefore prohibited.
397397
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void dropAndDeleteAnonymousDb() {
175175
assertThat(nameDb.get(txn, dbNameBuffer), is(nullValue()));
176176
txn.commit();
177177
}
178-
178+
179179
nameDb.close(); // explicit close after drop is OK
180180
}
181181

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,21 @@ public void mapFull() throws IOException {
250250
}
251251
}
252252

253+
@Test
254+
public void readOnlySupported() throws IOException {
255+
final File path = tmp.newFolder();
256+
try (Env<ByteBuffer> rwEnv = create().open(path)) {
257+
final Dbi<ByteBuffer> rwDb = rwEnv.openDbi(DB_1, MDB_CREATE);
258+
rwDb.put(bb(1), bb(42));
259+
}
260+
try (Env<ByteBuffer> roEnv = create().open(path, MDB_RDONLY_ENV)) {
261+
final Dbi<ByteBuffer> roDb = roEnv.openDbi(DB_1);
262+
try (Txn<ByteBuffer> roTxn = roEnv.txnRead()) {
263+
assertThat(roDb.get(roTxn, bb(1)), notNullValue());
264+
}
265+
}
266+
}
267+
253268
@Test
254269
public void setMapSize() throws IOException {
255270
final File path = tmp.newFolder();
@@ -258,7 +273,7 @@ public void setMapSize() throws IOException {
258273
final ByteBuffer val = allocateDirect(1_024);
259274
final Random rnd = new Random();
260275
try (Env<ByteBuffer> env = create().setMapSize(50_000)
261-
.setMaxDbs(1).open(path)) {
276+
.setMaxDbs(1).open(path)) {
262277
final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
263278

264279
db.put(bb(1), bb(42));
@@ -298,21 +313,6 @@ public void setMapSize() throws IOException {
298313
}
299314
}
300315

301-
@Test
302-
public void readOnlySupported() throws IOException {
303-
final File path = tmp.newFolder();
304-
try (Env<ByteBuffer> rwEnv = create().open(path)) {
305-
final Dbi<ByteBuffer> rwDb = rwEnv.openDbi(DB_1, MDB_CREATE);
306-
rwDb.put(bb(1), bb(42));
307-
}
308-
try (Env<ByteBuffer> roEnv = create().open(path, MDB_RDONLY_ENV)) {
309-
final Dbi<ByteBuffer> roDb = roEnv.openDbi(DB_1);
310-
try (Txn<ByteBuffer> roTxn = roEnv.txnRead()) {
311-
assertThat(roDb.get(roTxn, bb(1)), notNullValue());
312-
}
313-
}
314-
}
315-
316316
@Test
317317
public void stats() throws IOException {
318318
final File path = tmp.newFile();

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,41 @@ public void largeKeysRejected() throws IOException {
9595
dbi.put(key, bb(2));
9696
}
9797

98+
@Test
99+
public void rangeSearch() {
100+
final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
101+
102+
final ByteBuffer key = allocateDirect(env.getMaxKeySize());
103+
key.put("cherry".getBytes(UTF_8)).flip();
104+
db.put(key, bb(1));
105+
106+
key.clear();
107+
key.put("strawberry".getBytes(UTF_8)).flip();
108+
db.put(key, bb(3));
109+
110+
key.clear();
111+
key.put("pineapple".getBytes(UTF_8)).flip();
112+
db.put(key, bb(2));
113+
114+
try (Txn<ByteBuffer> txn = env.txnRead()) {
115+
final ByteBuffer start = allocateDirect(env.getMaxKeySize());
116+
start.put("a".getBytes(UTF_8)).flip();
117+
118+
final ByteBuffer end = allocateDirect(env.getMaxKeySize());
119+
end.put("z".getBytes(UTF_8)).flip();
120+
121+
final List<String> keysFound = new ArrayList<>();
122+
final CursorIterator<ByteBuffer> ckr = db.iterate(txn, KeyRange.closed(
123+
start, end));
124+
for (final CursorIterator.KeyVal<ByteBuffer> kv : ckr.iterable()) {
125+
keysFound.add(UTF_8.decode(kv.key()).toString());
126+
}
127+
128+
assertEquals(3, keysFound.size());
129+
130+
}
131+
}
132+
98133
@Test
99134
public void readOnlyTxnAllowedInReadOnlyEnv() {
100135
env.openDbi(DB_1, MDB_CREATE);
@@ -266,39 +301,4 @@ public void zeroByteKeysRejected() throws IOException {
266301
dbi.put(key, bb(2));
267302
}
268303

269-
270-
@Test
271-
public void rangeSearch() {
272-
final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
273-
274-
final ByteBuffer key = allocateDirect(env.getMaxKeySize());
275-
key.put("cherry".getBytes(UTF_8)).flip();
276-
db.put(key, bb(1));
277-
278-
key.clear();
279-
key.put("strawberry".getBytes(UTF_8)).flip();
280-
db.put(key, bb(3));
281-
282-
key.clear();
283-
key.put("pineapple".getBytes(UTF_8)).flip();
284-
db.put(key, bb(2));
285-
286-
try (Txn<ByteBuffer> txn = env.txnRead()) {
287-
final ByteBuffer start = allocateDirect(env.getMaxKeySize());
288-
start.put("a".getBytes(UTF_8)).flip();
289-
290-
final ByteBuffer end = allocateDirect(env.getMaxKeySize());
291-
end.put("z".getBytes(UTF_8)).flip();
292-
293-
final List<String> keysFound = new ArrayList<>();
294-
final CursorIterator<ByteBuffer> ckr = db.iterate(txn, KeyRange.closed(start, end));
295-
for (final CursorIterator.KeyVal<ByteBuffer> kv : ckr.iterable()) {
296-
keysFound.add(UTF_8.decode(kv.key()).toString());
297-
}
298-
299-
assertEquals(3, keysFound.size());
300-
301-
}
302-
}
303-
304304
}

0 commit comments

Comments
 (0)