|
19 | 19 | import static com.jakewharton.byteunits.BinaryByteUnit.KIBIBYTES; |
20 | 20 | import static java.nio.ByteBuffer.allocateDirect; |
21 | 21 | import static org.assertj.core.api.Assertions.assertThat; |
22 | | -import static org.lmdbjava.DbiFlags.*; |
| 22 | +import static org.lmdbjava.DbiFlags.MDB_CREATE; |
| 23 | +import static org.lmdbjava.DbiFlags.MDB_DUPSORT; |
| 24 | +import static org.lmdbjava.DbiFlags.MDB_INTEGERKEY; |
23 | 25 | import static org.lmdbjava.Env.create; |
24 | 26 | import static org.lmdbjava.EnvFlags.MDB_NOSUBDIR; |
25 | | -import static org.lmdbjava.TestUtils.*; |
| 27 | +import static org.lmdbjava.TestUtils.DB_1; |
| 28 | +import static org.lmdbjava.TestUtils.POSIX_MODE; |
| 29 | +import static org.lmdbjava.TestUtils.bb; |
26 | 30 |
|
27 | | -import java.io.*; |
| 31 | +import java.io.File; |
| 32 | +import java.io.FileReader; |
| 33 | +import java.io.IOException; |
| 34 | +import java.io.Reader; |
| 35 | +import java.io.StringWriter; |
| 36 | +import java.io.UncheckedIOException; |
| 37 | +import java.io.Writer; |
28 | 38 | import java.nio.ByteBuffer; |
29 | 39 | import java.nio.ByteOrder; |
30 | 40 | import java.nio.file.Path; |
@@ -231,96 +241,6 @@ private long getLong(final ByteBuffer byteBuffer, final ByteOrder byteOrder) { |
231 | 241 | } |
232 | 242 | } |
233 | 243 |
|
234 | | - // |
235 | | - // @Test |
236 | | - // void testSignedComparator() throws IOException { |
237 | | - // test(ByteBuffer::compareTo, true, "testSignedComparator", 1, MDB_CREATE); |
238 | | - // } |
239 | | - // |
240 | | - // @Test |
241 | | - // void testUnsignedComparator() throws IOException { |
242 | | - // test(AbstractByteBufferProxy::compareBuff, false, "testUnsignedComparator", 1, MDB_CREATE); |
243 | | - // } |
244 | | - // |
245 | | - // @Test |
246 | | - // void testSignedComparatorDupsort() throws IOException { |
247 | | - // test(ByteBuffer::compareTo, true, "testSignedComparatorDupsort", 2, MDB_CREATE, |
248 | | - // MDB_DUPSORT); |
249 | | - // } |
250 | | - // |
251 | | - // @Test |
252 | | - // void testUnsignedComparatorDupsort() throws IOException { |
253 | | - // test(AbstractByteBufferProxy::compareBuff, false, "testUnsignedComparatorDupsort", 2, |
254 | | - // MDB_CREATE, MDB_DUPSORT); |
255 | | - // } |
256 | | - // |
257 | | - // private void test(final Comparator<ByteBuffer> comparator, |
258 | | - // final boolean nativeCb, |
259 | | - // final String testName, |
260 | | - // final BiConsumer<Env<ByteBuffer>, Dbi<ByteBuffer>> dbPopulator, |
261 | | - // final DbiFlags... flags) throws IOException { |
262 | | - // final Path dbPath = Files.createTempFile("test", "db"); |
263 | | - // try (final Env<ByteBuffer> env = |
264 | | - // create() |
265 | | - // .setMapSize(KIBIBYTES.toBytes(256)) |
266 | | - // .setMaxReaders(1) |
267 | | - // .setMaxDbs(1) |
268 | | - // .open(dbPath.toFile(), POSIX_MODE, MDB_NOSUBDIR)) { |
269 | | - // final Dbi<ByteBuffer> dbi = env.openDbi(DB_1, comparator, nativeCb, flags); |
270 | | - // dbPopulator.accept(env, dbi); |
271 | | - // |
272 | | - // final File tests = new File("src/test/resources/CursorIterableRangeTest/tests.csv"); |
273 | | - // final File actual = tests.getParentFile().toPath().resolve(testName + ".actual").toFile(); |
274 | | - // final File expected = tests.getParentFile().toPath().resolve(testName + |
275 | | - // ".expected").toFile(); |
276 | | - // final String csv = readFile(tests); |
277 | | - // final String[] parts = csv.split("\n"); |
278 | | - // try (final Writer writer = new FileWriter(actual)) { |
279 | | - // for (final String part : parts) { |
280 | | - // final String[] params = part.split(","); |
281 | | - // final KeyRangeType keyRangeType = KeyRangeType.valueOf(params[0].trim()); |
282 | | - // ByteBuffer start = null; |
283 | | - // ByteBuffer stop = null; |
284 | | - // if (params.length > 1 && params[1].trim().length() > 0) { |
285 | | - // start = bb(Integer.parseInt(params[1].trim())); |
286 | | - // } |
287 | | - // if (params.length > 2 && params[2].trim().length() > 0) { |
288 | | - // stop = bb(Integer.parseInt(params[2].trim())); |
289 | | - // } |
290 | | - // |
291 | | - // for (int i = 0; i < 3; i++) { |
292 | | - // if (params.length > i) { |
293 | | - // writer.append(params[i].trim()); |
294 | | - // } |
295 | | - // writer.append(","); |
296 | | - // } |
297 | | - // |
298 | | - // final KeyRange<ByteBuffer> keyRange = new KeyRange<>(keyRangeType, start, stop); |
299 | | - // try (Txn<ByteBuffer> txn = env.txnRead(); |
300 | | - // CursorIterable<ByteBuffer> c = dbi.iterate(txn, keyRange)) { |
301 | | - // for (final KeyVal<ByteBuffer> kv : c) { |
302 | | - // final int key = kv.key().getInt(); |
303 | | - // final int val = kv.val().getInt(); |
304 | | - // writer.append("["); |
305 | | - // writer.append(String.valueOf(key)); |
306 | | - // writer.append(" "); |
307 | | - // writer.append(String.valueOf(val)); |
308 | | - // writer.append("]"); |
309 | | - // } |
310 | | - // } |
311 | | - // writer.append("\n"); |
312 | | - // } |
313 | | - // } |
314 | | - // |
315 | | - // // Compare files. |
316 | | - // final String act = readFile(actual); |
317 | | - // final String exp = readFile(expected); |
318 | | - // assertThat(act).withFailMessage("Files are not equal").isEqualTo(exp); |
319 | | - // } finally { |
320 | | - // FileUtil.deleteFile(dbPath); |
321 | | - // } |
322 | | - // } |
323 | | - |
324 | 244 | private BiConsumer<Env<ByteBuffer>, Dbi<ByteBuffer>> createBasicDBPopulator() { |
325 | 245 | return (env, dbi) -> { |
326 | 246 | try (Txn<ByteBuffer> txn = env.txnWrite()) { |
|
0 commit comments