I recently asked a question about Neo4j, which I got working and which seems nice. It's embeddable and it's written in Java and there aren't (too) many dependencies.
However it's a graph DB and I don't know if it's a good idea or not to use it as a simply key/value store.
Basically I've got a big map, which in Java would look like this:
Map<Integer,Map<String,String>>
I've got a few tens of millions of entries in the main map and each entry contains itself a map of property/values. The "inner" map is relatively small: about 20 entries.
I need a way to persist that map from on run of the webapp to the other.
Using Neo4j, what I did is create one node for every ID (integer) and then put one property for each entry inside the inner map. From my early testing it seems to work but I'm not sure it's a good way to proceed.
Which embeddable DB, written in Java, would you use?
The requirements are:
written in Java
embeddable (so nothing too big)
not SQL (*)
open source
easy to backup (I need to be able to make "live" backups, while the server is running)
My terminology may be a bit wrong too, so feel free to help me / correct me. For my "map of maps", the best fit would be a key/value pair DB right?
I'm a bit lost as the difference between key/value pairs DB, Document DBs, big tables, graph DBs, etc.
I'd also like if it's a good idea to use a graph DB like Neo4J for my need (I think performance really ain't going to be an issue seen the relatively small amount of entries I'll have).
Of course I could simply persist my map of maps myself but I really don't want to reinvent any wheel here. I want to reuse a tried and tested DB...
(*) The reason I do not want SQL is that I'll always have this "map of maps" and that the inner map is going to constantly evolve, so I don't want something too structured.
Of course, NoSQL encompasses a variety of database types, but easily the most popular is key-value store. This type of data model is built around its extreme simplicity, which allows it to perform blisteringly fast compared to relational databases.
A few of the dominant providers are H2, HyperSQL, Apache Derby, Berkley DB, Java DB, ObjectDB, and so forth. HyperSQL conforms to the SQL:2011 standard and JDBC 4 specification and supports every classical feature expected from a modern relational database.
Embedded key-value stores come with the additional baggage of embedded systems: they share resources with the system embedding them, which means efficiency is key.
Java DB. Java DB is Oracle's supported distribution of the open source Apache Derby database. Its ease of use, standards compliance, full feature set, and small footprint make it the ideal database for Java developers. Java DB is written in the Java programming language, providing "write once, run anywhere" portability ...
There seem to be a couple of ports of Google's LevelDB into Java:
Then there is a whole list of embedded Java databases here:
For your use case I would recommend MapDB (http://www.mapdb.org)
It matches your requirements:
and has other nice features like transactions, concurrency and performance.
Chronicle-Map
is a new nice player on this field.
Map
implementationConcurrentHashMap
)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With