use of org.mapdb.DB in project tdq-studio-se by Talend.
the class MapDBManager method addDBRef.
/**
* Record one db have been used how many times
*
* @param filePath
*/
public void addDBRef(File filePath) {
DB db = dbMap.get(filePath);
if (db == null) {
return;
}
cancelCloseTask(db);
Integer refConut = dbRefCountMap.get(db);
if (refConut == null) {
refConut = 0;
}
refConut++;
dbRefCountMap.put(db, refConut);
}
use of org.mapdb.DB in project tdq-studio-se by Talend.
the class MapDBManager method removeDBRef.
/**
* Reduce the times which one db be used. When the count of times is 0 we will close this db.
*
* @param filePath
*/
public void removeDBRef(File filePath) {
DB db = dbMap.get(filePath);
if (db == null) {
return;
}
Integer refConut = dbRefCountMap.get(db);
if (refConut == null) {
return;
}
refConut--;
if (refConut > 0) {
dbRefCountMap.put(db, refConut);
} else {
dbRefCountMap.remove(db);
closeDB(db, filePath);
}
}
use of org.mapdb.DB in project mapdb by jankotek.
the class Issue794 method test.
@Test
public void test() {
DB db = DBMaker.memoryDB().closeOnJvmShutdown().make();
DB.TreeMapSink<Long, DataPoint> sIds2DataPointSink = db.treeMap("ids2DataPoint", Serializer.LONG, Serializer.ELSA).valuesOutsideNodesEnable().createFromSink();
for (long i = 0; i < limit; i++) {
DataPoint point = new DataPoint();
point.add("aaa");
point.add("aaa");
point.add("aaa");
point.add("aaa");
//insert 70G DataPoint entities, each filled with 5 Strings
sIds2DataPointSink.put(i, point);
}
//here the error occurs
sIds2DataPointSink.create();
db.close();
}
use of org.mapdb.DB in project tdq-studio-se by Talend.
the class MapDBManager method closeDB.
/**
* If MapDB file is not exist or has been closed then this method will not do anything else will create new task to
* close it.
*
* @param analysis
*/
public void closeDB(File filePath) {
DB db = dbMap.get(filePath);
closeDB(db, filePath);
}
use of org.mapdb.DB in project tdq-studio-se by Talend.
the class MapDBManager method deleteDB.
/**
* Delete mapDB file
*
* @param analysis
*/
public void deleteDB(Analysis analysis) {
File mapDBFile = getMapDBFile(analysis);
DB db = this.getDB(mapDBFile);
// if db is in used close it first
if (db != null) {
this.removeDB(mapDBFile);
dbRefCountMap.remove(db);
db.close();
while (!db.isClosed()) {
try {
Thread.currentThread().wait(1000);
} catch (InterruptedException e) {
}
}
}
// delete data file and index file
if (mapDBFile.exists()) {
mapDBFile.delete();
new File(mapDBFile.getAbsolutePath() + StoreDirect.DATA_FILE_EXT).delete();
}
}
Aggregations