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


Java DB.isClosed方法代码示例

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


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

示例1: testHugeDataForTreeMap

import org.mapdb.DB; //导入方法依赖的package包/类
@Test
    public void testHugeDataForTreeMap() throws UnsupportedEncodingException{
    	setStartT();
    	DB fileDb =DBMaker.newTempFileDB().closeOnJvmShutdown().transactionDisable().make();
    	 DB db = DBMaker.newMemoryDirectDB().sizeLimit(0.1).closeOnJvmShutdown().transactionDisable().make();
    	 BTreeMap<Fun.Tuple2<String, Long>,Long> memoryDbMap = db.createTreeMap("test").keySerializer(BTreeKeySerializer.TUPLE2).valueSerializer(Serializer.LONG).make();
    	 BTreeMap<String, Long> fileDbMap=null;//= fileDb.createTreeMap("test").keySerializer(BTreeKeySerializer.STRING).valueSerializer(Serializer.LONG).make();
//    	 HTreeMap<String, Long> memoryDbMap = db.createHashMap("test").keySerializer(Serializer.STRING).valueSerializer(Serializer.LONG).make();
//    	 HTreeMap<String, Long> fileDbMap= fileDb.createHashMap("test").keySerializer(Serializer.STRING).valueSerializer(Serializer.LONG).make();
    	 Store memoryDbStore = Store.forDB(db);
    	 Store fileDbStore = Store.forDB(fileDb);
    	for(int index=0;index<1e7;index++){
    		if(memoryDbStore.getSizeLimit()-memoryDbStore.getCurrSize()<=1024*1024*1){
//    			System.out.println(store.calculateStatistics());
    			//copy data to file when the size of memory is too large
    			System.out.println(memoryDbStore.getCurrSize()/1024);
    			ellipseT();
    			fileDbMap=copyDataToFile(memoryDbMap,fileDb);
    			db.close();
    			db = DBMaker.newMemoryDirectDB().sizeLimit(0.1).closeOnJvmShutdown().transactionDisable().make();
    	    	memoryDbMap = db.createTreeMap("test").keySerializer(BTreeKeySerializer.TUPLE2).valueSerializer(Serializer.LONG).make();
//    	    	memoryDbMap = db.createHashMap("test").keySerializer(Serializer.STRING).valueSerializer(Serializer.LONG).make();
    	    	memoryDbStore = Store.forDB(db);
    		}
    		for(String[] dataItem:initRandomData()){
    			String convertToKey = ConvertToKey(dataItem);
    			
    			memoryDbMap.put(Fun.t2(convertToKey, new Random().nextLong()), 1l);
    		}
    			
    	}
//    	for(int index=0;index<3.75e4;index++){
//    		if(memoryDbStore.getSizeLimit()-memoryDbStore.getCurrSize()<=1024*1024*1){
////    			System.out.println(store.calculateStatistics());
//    			//copy data to file when the size of memory is too large
//    			System.out.println(memoryDbStore.getCurrSize()/1024);
//    			ellipseT();
//    			copyDataToFile(memoryDbMap,fileDb);
//    			db.close();
//    			db = DBMaker.newMemoryDirectDB().sizeLimit(0.05).closeOnJvmShutdown().transactionDisable().make();
//    			memoryDbMap = db.createTreeMap("test").keySerializer(BTreeKeySerializer.STRING).valueSerializer(Serializer.LONG).make();
////    			memoryDbMap = db.createHashMap("test").keySerializer(Serializer.STRING).valueSerializer(Serializer.LONG).make();
//    			memoryDbStore = Store.forDB(db);
//    		}
//    		for(String[] dataItem:initData()){
//    			Tuple2<String, Long> t2 = Fun.t2(ConvertToKey(dataItem), 1l);
//    			Long frequency = memoryDbMap.get(t2);
//    			if(frequency!=null){
//    				frequency++;
//    				t2=Fun.t2(t2.a, frequency);
//    			}else{
//    				frequency=1l;
//    			}
//    			memoryDbMap.put(t2, frequency);
//    		}
//    		
//    	}
    	
    	//copy last data which leave at memory
    	System.out.println(memoryDbStore.getCurrSize()/1024);
		ellipseT();
		fileDbMap=copyDataToFile(memoryDbMap,fileDb);
		db.close();
		
    	System.out.println(fileDbStore.getCurrSize()/1024);
    	ellipseT();
    	computeResult(fileDbMap);
    	ellipseT();
//    	Assert.assertEquals(10l, distinctCount.longValue());
    	Assert.assertEquals(10l, rowCount.longValue());
    	Assert.assertEquals(uniqueCount.longValue(), distinctCount.longValue()-duplicateCount.longValue());
//    	Assert.assertEquals(0l, uniqueCount.longValue());
//    	Assert.assertEquals(10l, duplicateCount.longValue());
    	fileDb.close();
    	if(!db.isClosed()){
    		db.close();
    	}
    }
 
开发者ID:sizhaoliu,项目名称:MemoryManagementBenchmark,代码行数:79,代码来源:TupleMapDBTestForMixMode.java

示例2: closeMapDBIndex

import org.mapdb.DB; //导入方法依赖的package包/类
private void closeMapDBIndex(final DB mapDBIndex) {

		if (mapDBIndex != null && !mapDBIndex.isClosed()) {

			mapDBIndex.close();
		}
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:8,代码来源:NamespaceIndex.java

示例3: closeMapDBIndex

import org.mapdb.DB; //导入方法依赖的package包/类
private void closeMapDBIndex(final DB mapDBIndex) {

		if (mapDBIndex != null && !mapDBIndex.isClosed()) {

			try {

				mapDBIndex.close();
			} catch (final RuntimeException e) {

				LOG.error("could not close mapdb index properly.", e);
			}
		}
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:14,代码来源:BasicNeo4jProcessor.java


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