本文整理汇总了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();
}
}
示例2: closeMapDBIndex
import org.mapdb.DB; //导入方法依赖的package包/类
private void closeMapDBIndex(final DB mapDBIndex) {
if (mapDBIndex != null && !mapDBIndex.isClosed()) {
mapDBIndex.close();
}
}
示例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);
}
}
}