Which embedded DB written in Java for a simple key/value store?

Cedric Martin picture Cedric Martin · Mar 19, 2012 · Viewed 30.2k times · Source

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.

Answer

Kiril picture Kiril · Mar 19, 2012

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: