当前位置: 首页>>代码示例>>Java>>正文


Java DBMaker.make方法代码示例

本文整理汇总了Java中org.mapdb.DBMaker.make方法的典型用法代码示例。如果您正苦于以下问题:Java DBMaker.make方法的具体用法?Java DBMaker.make怎么用?Java DBMaker.make使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mapdb.DBMaker的用法示例。


在下文中一共展示了DBMaker.make方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import org.mapdb.DBMaker; //导入方法依赖的package包/类
@Override
public void open() {
	File file = new File(databaseDir_);
	if (!file.exists()) {
		file.mkdirs();
	}
	try {
		File dbFile = File.createTempFile(DATABASE_NAME, "db", file);
		DBMaker maker = DBMaker
			    .newFileDB(dbFile)
			    .transactionDisable()
			    .asyncWriteQueueSize(5000)
			    .mmapFileEnableIfSupported();
		if(this.getCompressMode()){
		    maker.compressionEnable();
		}
		mdb_ = maker.make();
		map_ = mdb_.createHashMap(MAP_NAME)
			.hasher(Hasher.BYTE_ARRAY)
			.makeOrGet();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:ppdai,项目名称:sessdb,代码行数:26,代码来源:MdbBenchmark.java

示例2: start

import org.mapdb.DBMaker; //导入方法依赖的package包/类
@Override
public void start() {
   expiryEntryQueue = new LinkedBlockingQueue<ExpiryEntry>(configuration.expiryQueueSize());
   File location = new File(configuration.location());
   location.mkdirs();
   File dbFile = new File(location, "mapdb");
   DBMaker<?> dbMaker = DBMaker.newFileDB(dbFile)
         .transactionDisable()
         .asyncWriteDisable();
   
   if (configuration.compression())
      dbMaker.compressionEnable();
   
   this.db = dbMaker.make();
   
   
   this.store = db.createHashMap(STORE_DB_NAME)
         .makeOrGet();
   this.expired = db.createHashMap(EXPIRY_DB_NAME)
         .makeOrGet();
}
 
开发者ID:saturnism,项目名称:infinispan-cachestore-mapdb,代码行数:22,代码来源:MapDBStore.java

示例3: start

import org.mapdb.DBMaker; //导入方法依赖的package包/类
@Override
public void start() {
   expiryEntryQueue = new LinkedBlockingQueue<ExpiryEntry>(configuration.expiryQueueSize());
   DBMaker<?> dbMaker = DBMaker.newDirectMemoryDB()
         .transactionDisable().asyncWriteDisable();
         //.asyncFlushDelay(100);
   
   if (configuration.compression())
      dbMaker.compressionEnable();
   
   this.db = dbMaker.make();
   
   
   this.store = db.createHashMap(STORE_DB_NAME + cache.getName())
         .makeOrGet();
   this.expired = db.createHashMap(EXPIRY_DB_NAME + cache.getName())
         .makeOrGet();
}
 
开发者ID:saturnism,项目名称:infinispan-cachestore-offheap,代码行数:19,代码来源:OffheapStore.java

示例4: init

import org.mapdb.DBMaker; //导入方法依赖的package包/类
private void init() {
  DBMaker maker;
  if (file == null)
    maker = DBMaker.newMemoryDB();
  else {
    if (overwrite)
      wipe(file);
    maker = DBMaker.newFileDB(new File(file));
    maker = maker.cacheSize(cache_size);
    if (async) {
      maker = maker.asyncWriteEnable();
      maker = maker.asyncWriteFlushDelay(10000);
    }
    if (mmap)
      maker = maker.mmapFileEnableIfSupported();
    if (compression)
      maker = maker.compressionEnable();
    if (snapshot)
      maker = maker.snapshotEnable();
    if (notxn)
      maker = maker.transactionDisable();
  }

  db = maker.make();

  if (!db.exists("idmap"))
    idmap = db.createHashMap("idmap")
      .valueSerializer(new RecordSerializer())
      .make();
  else
    idmap = db.getHashMap("idmap");
}
 
开发者ID:enricopal,项目名称:STEM,代码行数:33,代码来源:MapDBBlockingDatabase.java

示例5: build

import org.mapdb.DBMaker; //导入方法依赖的package包/类
public MicroDB build(File path) throws IOException {
    DBMaker mapdbBuilder = DBMaker.newFileDB(path);
    if(mCacheSize != null) {
        mapdbBuilder.cacheSize(mCacheSize);
    }
    DB db = mapdbBuilder.make();

    MapDBDriver driver = new MapDBDriver(db);

    return new MicroDB(driver, mSchemaVersion, mCallback, mConstructorMap);

}
 
开发者ID:dinocore1,项目名称:MicroDb,代码行数:13,代码来源:DBBuilder.java

示例6: MapdbStorageEngine

import org.mapdb.DBMaker; //导入方法依赖的package包/类
protected MapdbStorageEngine(DBMaker dbMaker, Serializer... serializers) {
    this.dbMaker = dbMaker;
    this.serializers = serializers;
    this.db = dbMaker.make();
}
 
开发者ID:jhendess,项目名称:metadict,代码行数:6,代码来源:MapdbStorageEngine.java

示例7: onInit

import org.mapdb.DBMaker; //导入方法依赖的package包/类
@Override
public void onInit() {
	if (LOG.isTraceEnabled()) {
		LOG.trace("Initializing the '"
				+ MapDbAuthorizingRealm.class.getSimpleName() + "'.");
	}

	super.onInit();

	// create the maker of the database and create it
	final DBMaker<?> maker = DBMaker.newFileDB(location);
	maker.cacheHardRefEnable();
	maker.cacheLRUEnable();
	maker.cacheSize(1000);
	maker.closeOnJvmShutdown();
	db = maker.make();

	// create the maker for the specific maps of users and roles
	final HTreeMapMaker usersMapMaker = db.createHashMap("users");
	final HTreeMapMaker rolesMapMaker = db.createHashMap("roles");
	this.users = usersMapMaker.makeOrGet();
	this.roles = rolesMapMaker.makeOrGet();

	// disable any caching
	setCachingEnabled(false);
	setCacheManager(null);

	// add a role resolver
	setRolePermissionResolver(new RolePermissionResolver() {

		@Override
		public Collection<Permission> resolvePermissionsInRole(
				final String role) {

			final SimpleRole r = roles.get(role);
			if (r == null) {
				return null;
			} else {
				return r.getPermissions();
			}
		}
	});

	checkAdministrator();
}
 
开发者ID:pmeisen,项目名称:dis-timeintervaldataanalyzer,代码行数:46,代码来源:MapDbAuthorizingRealm.java

示例8: CachingRemoteConnector

import org.mapdb.DBMaker; //导入方法依赖的package包/类
/**
 * Creates a connector that caches items read from the server
 * @param delegate the underlying connector
 * @param cacheFile a file used to cache items
 */
public CachingRemoteConnector(RemoteConnector delegate, File cacheFile) {
	super(delegate);
	
	DB db = null;
	Set<String> itemIds = null;
	Map<String, String> items = null;
	int retry = 2;
	while (retry >= 1) {
		try {
			DBMaker<?> dbMaker = DBMaker.newFileDB(cacheFile);
			dbMaker.closeOnJvmShutdown();
			db = dbMaker.make();
			
			itemIds = db.getTreeSet("itemIds");
			items = db.getHashMap("items");
			
			break;
		} catch (Throwable e) {
			--retry;
			if (retry == 1 && cacheFile.exists()) {
				//unable to open disk cache. remove it and try again.
				try {
					//close db first
					if (db != null) {
						db.close();
						db = null;
					}
				} catch (Throwable t) {
					//ignore
				}
				cacheFile.delete();
				continue;
			}
			
			//disk cache is not available. use in-memory cache
			db = null;
			itemIds = new HashSet<>();
			items = new HashMap<>();
			break;
		}
	}
	
	_db = db;
	_itemIds = itemIds;
	_items = items;
}
 
开发者ID:michel-kraemer,项目名称:citeproc-java,代码行数:52,代码来源:CachingRemoteConnector.java

示例9: IdStore

import org.mapdb.DBMaker; //导入方法依赖的package包/类
public IdStore(File directory, String idName) {

        if(!directory.exists())
            directory.mkdirs();

        DBMaker dbm = DBMaker.newFileDB(new File(directory, "id_" + idName + ".db"))
                .mmapFileEnableIfSupported()
                .closeOnJvmShutdown();

        db = dbm.make();

        id = db.createAtomicLong(idName, INITIAL_VALUE);
    }
 
开发者ID:opentraffic,项目名称:traffic-engine,代码行数:14,代码来源:IdStore.java


注:本文中的org.mapdb.DBMaker.make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。