I am using MapDB for key-value database for the better performace.After the map.clear() my files are not deleted in disk.I need to reclaim the diskspace after the remove() or clear() method.Below are the my code sippet.
public static void mapDBPerformanceonFileDBStack() throws Exception{
String fileName ="testdatabase.db";
DB db = DBMaker
.fileDB(fileName)
.closeOnJvmShutdown()
.make();
Map myMap = db.hashMap("testmap").keySerializer(Serializer.INTEGER).valueSerializer(Serializer.STRING).createOrOpen();
System.out.println("Intial mapsize :" +myMap.size());
for(int i=0;i<100000;i++){
myMap.put(i,"key added" );
}
db.commit();
System.out.println("mapsize after the addition :"+myMap.size());
myMap.clear();
System.out.println("mapsize after clear :"+myMap.size());
db.commit();
db.close();
}
My testdatabase file size not reclaimed after the map.clear() - Same size after the clear().