I can't understand where and when I have to put these two instruction when using MapDB:
db.commit()
db.close()
Commit is for when I modify the data in the db, ok. But every time I instantiate this kind of objects in a method (that is, every time I need access to the db):
DB db = DBMaker.newFileDB(new File(FILE_NAME)).closeOnJvmShutdown().make();
ConcurrentNavigableMap<Integer, Offers> offerts= db.getTreeMap("offers");
do I have to put the db.close() instruction at the end of the method? And what about the db.commit()? Only if I modify the data?
I'm asking this because I'm facing this kind of error:
java.lang.RuntimeException: Writer thread failed
Caused by:
java.lang.ArrayIndexOutOfBoundsException: -1811939328
at org.mapdb.Volume$ByteBufferVol.tryAvailable(Volume.java:273)
at org.mapdb.Volume.ensureAvailable(Volume.java:58)
at org.mapdb.StoreWAL.replayLogFile(StoreWAL.java:621)
at org.mapdb.StoreWAL.commit(StoreWAL.java:579)
at org.mapdb.EngineWrapper.commit(EngineWrapper.java:95)
at org.mapdb.AsyncWriteEngine.access$201(AsyncWriteEngine.java:72)
at org.mapdb.AsyncWriteEngine.runWriter(AsyncWriteEngine.java:230)
at org.mapdb.AsyncWriteEngine$WriterRunnable.run(AsyncWriteEngine.java:156)
at java.lang.Thread.run(Unknown Source)
My MapDB version is 0.9.7.
0.9.7 had bugs, please update to newer version.
If you create new collection, you need to make commit, else changes will not be preserved.