本文整理汇总了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);
}