本文整理匯總了Java中org.mapdb.DBMaker.Maker方法的典型用法代碼示例。如果您正苦於以下問題:Java DBMaker.Maker方法的具體用法?Java DBMaker.Maker怎麽用?Java DBMaker.Maker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mapdb.DBMaker
的用法示例。
在下文中一共展示了DBMaker.Maker方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createMmapFile
import org.mapdb.DBMaker; //導入方法依賴的package包/類
public static MapDbAppStorage createMmapFile(String fileSystemName, File dbFile) {
return new MapDbAppStorage(fileSystemName, () -> {
DBMaker.Maker maker = DBMaker.fileDB(dbFile)
.transactionEnable();
// it is not recommanded to use mmap on Windows (crash)
// http://www.mapdb.org/blog/mmap_files_alloc_and_jvm_crash/
if (!SystemUtils.IS_OS_WINDOWS) {
maker.fileMmapEnableIfSupported()
.fileMmapPreclearDisable();
}
return maker.make();
});
}
示例2: createDB
import org.mapdb.DBMaker; //導入方法依賴的package包/類
private DB createDB(String name, boolean transactional) {
File dbFile = new File(getProperty("user.dir") + "/" + config.databaseDir() + "/" + name);
if (!dbFile.getParentFile().exists()) {
dbFile.getParentFile().mkdirs();
}
DBMaker.Maker dbMaker = DBMaker.fileDB(dbFile)
.closeOnJvmShutdown();
if (!transactional) {
dbMaker.transactionDisable();
}
return dbMaker.make();
}
示例3: testObjs
import org.mapdb.DBMaker; //導入方法依賴的package包/類
@Test
public void testObjs() throws Exception {
//final File dbf = File.createTempFile("clb", "x");
final String dbf = "/tmp/clb-"+ UUID.randomUUID()+".db";
final DBMaker.Maker dbm = DBMaker
.fileDB(dbf)
.fileMmapEnableIfSupported() // Only enable mmap on supported (64bit) platforms
.cleanerHackEnable() // Make mmap file faster
;
// warmup db & kryo
DB db = dbm.make();
Map<Long, LookupUsage> kvp = getMap(db);
kvp.put(1l, usage(1));
kvp.clear();
// start
long start = System.currentTimeMillis();
for (long x = 0l; x < repeat; x++) {
kvp.put(x, usage((int) x));
}
db.commit();
logRate("write", start);
db.close();
// open again and read
db = dbm.make();
kvp = getMap(db);
start = System.currentTimeMillis();
for (long x = 0; x < repeat; x++) {
LookupUsage u2 = kvp.get(x);
assertNotNull("Not in map", u2);
}
db.commit();
logRate("read", start);
db.close();
}
示例4: createMem
import org.mapdb.DBMaker; //導入方法依賴的package包/類
public static MapDbAppStorage createMem(String fileSystemName) {
DBMaker.Maker maker = DBMaker.memoryDB();
return new MapDbAppStorage(fileSystemName, maker::make);
}
示例5: createHeap
import org.mapdb.DBMaker; //導入方法依賴的package包/類
public static MapDbAppStorage createHeap(String fileSystemName) {
DBMaker.Maker maker = DBMaker.heapDB();
return new MapDbAppStorage(fileSystemName, maker::make);
}