public void runTest(DatabaseType type) throws DatabaseException, FileNotFoundException { int i; DatabaseConfig conf = new DatabaseConfig(); conf.setErrorStream(TestUtils.getErrorStream()); conf.setErrorPrefix("HashCompareTest"); conf.setType(type); if (type == DatabaseType.HASH) { conf.setHashComparator(new HashComparator()); } else conf.setBtreeComparator(new BtreeComparator()); conf.setAllowCreate(true); Database db = new Database(HASHCOMPARETEST_DBNAME, null, conf); DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry("world".getBytes()); for (i = 0; i < 100; i++) { key.setData((new String("key" + i)).getBytes()); db.put(null, key, data); } i = 0; Cursor dbc; dbc = db.openCursor(null, CursorConfig.DEFAULT); while (dbc.getNext(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) { ++i; } // System.out.println("retrieved " + i + " entries"); dbc.close(); db.close(); }