當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。