Skip to content

Commit c9161e1

Browse files
committed
Automatic formatting only
1 parent b3aa6bb commit c9161e1

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

src/main/java/org/lmdbjava/Dbi.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,29 @@ public CursorIterator<T> iterate(final Txn<T> txn, final KeyRange<T> range,
354354
return new CursorIterator<>(txn, this, range, useComp);
355355
}
356356

357+
/*
358+
* Return DbiFlags for this Dbi.
359+
*
360+
* @param txn transaction handle (not null; not committed)
361+
* @return the list of flags this Dbi was created with
362+
*/
363+
public List<DbiFlags> listFlags(final Txn<T> txn) {
364+
final IntByReference resultPtr = new IntByReference();
365+
checkRc(LIB.mdb_dbi_flags(txn.pointer(), ptr, resultPtr));
366+
367+
final int flags = resultPtr.intValue();
368+
369+
final List<DbiFlags> result = new ArrayList<>();
370+
371+
for (final DbiFlags flag : DbiFlags.values()) {
372+
if (isSet(flags, flag)) {
373+
result.add(flag);
374+
}
375+
}
376+
377+
return result;
378+
}
379+
357380
/**
358381
* Create a cursor handle.
359382
*
@@ -493,29 +516,6 @@ public Stat stat(final Txn<T> txn) {
493516
stat.f5_ms_entries.longValue());
494517
}
495518

496-
/*
497-
* Return DbiFlags for this Dbi.
498-
*
499-
* @param txn transaction handle (not null; not committed)
500-
* @return the list of flags this Dbi was created with
501-
*/
502-
public List<DbiFlags> listFlags(final Txn<T> txn) {
503-
final IntByReference resultPtr = new IntByReference();
504-
checkRc(LIB.mdb_dbi_flags(txn.pointer(), ptr, resultPtr));
505-
506-
final int flags = resultPtr.intValue();
507-
508-
final List<DbiFlags> result = new ArrayList<>();
509-
510-
for (final DbiFlags flag : DbiFlags.values()) {
511-
if (isSet(flags, flag)) {
512-
result.add(flag);
513-
}
514-
}
515-
516-
return result;
517-
}
518-
519519
private void clean() {
520520
if (cleaned) {
521521
return;

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,17 @@ public void getNamesWhenEmpty() {
263263
assertThat(dbiNames, empty());
264264
}
265265

266+
@Test
267+
public void listsFlags() {
268+
final Dbi<ByteBuffer> dbi = env.openDbi(DB_1, MDB_CREATE, MDB_DUPSORT,
269+
MDB_REVERSEKEY);
270+
271+
try (Txn<ByteBuffer> txn = env.txnRead()) {
272+
final List<DbiFlags> flags = dbi.listFlags(txn);
273+
assertThat(flags, containsInAnyOrder(MDB_DUPSORT, MDB_REVERSEKEY));
274+
}
275+
}
276+
266277
@Test
267278
public void putAbortGet() {
268279
final Dbi<ByteBuffer> db = env.openDbi(DB_1, MDB_CREATE);
@@ -478,13 +489,4 @@ public void testParallelWritesStress() {
478489
});
479490
}
480491

481-
@Test
482-
public void listsFlags() {
483-
final Dbi<ByteBuffer> dbi = env.openDbi(DB_1, MDB_CREATE, MDB_DUPSORT, MDB_REVERSEKEY);
484-
485-
try (Txn<ByteBuffer> txn = env.txnRead()) {
486-
final List<DbiFlags> flags = dbi.listFlags(txn);
487-
assertThat(flags, containsInAnyOrder(MDB_DUPSORT, MDB_REVERSEKEY));
488-
}
489-
}
490492
}

0 commit comments

Comments
 (0)