jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.87k stars 873 forks source link

Question on how data is persisted #1027

Closed siddhsql closed 9 months ago

siddhsql commented 10 months ago

Hello,

I came across this library recently. I have some questions:

  1. First, if I create a fileDB, do I need to close it (by calling close method) to save the data?
  2. Second, does it do a complete overwrite of everything to disk every time close is called? E.g., I create a hashmap of 1 billion elements and I call close. Then I add 1 more element and call close. What happens?
jankotek commented 9 months ago

You need to call close(), else files may get corrupted. Content of files is persisted after you close file. So you will have billion plus one entries.