Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java embedded library on-disk key-value database [closed]

What I think I'm looking for is a no-SQL, library-embedded, on disk (ie not in-memory) database, thats accessible from java (and preferably runs inside my instance of the JVM). That's not really much of a database, and I'm tempted to roll-my-own. Basically I'm looking for the "should we keep this in memory or put it on disk" portion of a database.

Our model has grown to several gigabytes. Right now this is all done in memory, meaning we're pushing the JVM for upward of several gigabytes. It's currently all stored in a flat XML file, serialized and deserialized with xstream and compressed with Java'a built in gzip libraries. That's worked well when our model stays under 100MB, but now that its larger than that its becoming a problem.

loosely speaking that model can be broken down as

  • Project
    1. configuration component (directed-acyclic-graph), not at all database friendly
    2. a list of a dozen "experiment" structures
      • each containing a list of about a dozen "run-model" structures.
        1. each run-model contains hundreds of megs of data. Once written they are never edited.

What I'd like to do is have something that conforms to a map interface, of guid -> run-model. This mini-database would keep a flat table of these objects. On our experiment model, we would replace the list of run-models with a list of guids, and add, at the application layer, a get call to this map, which would pull it off the disk and into memory.

That means we can keep configuration of our program in XML (which I'm very happy with) and keep a table of the big data in a DBMS that will keep us from consuming multi-GB of memory. On program start and exit I could then load and unload the two portions of our model (the config section in XML, and the run-models in the database format) from an archiving format.

I'm sort've feeling gung-ho about this, and think that I could probably implement it with some of X-Stream's XML inspection strategies and a custom map implementation, but something a voice in the back of my head is telling me I should find a library to do it instead.

Should I roll my own or is there a database that's small enough to fit this bill?

Thanks guys,

-Geoff

like image 990
Groostav Avatar asked Mar 05 '14 00:03

Groostav


People also ask

What is embedded database in Java?

An embedded database means that the database is integrated as an inseparable part of an application software. A Java application, in particular, accesses the database using a JDBC driver. The database engine runs as a cohort inside the same JVM while the application is running.

What is an embedded key-value store?

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.

What is the use of key-value Datastore?

A key-value database is a type of nonrelational database that uses a simple key-value method to store data. A key-value database stores data as a collection of key-value pairs in which a key serves as a unique identifier. Both keys and values can be anything, ranging from simple objects to complex compound objects.

What is in memory key-value store?

On the technical side, key-value stores are commonly used for in-memory data caching to speed up applications by minimizing reads and writes to slower disk-based systems. Hazelcast is an example of a technology that provides an in-memory key-value store for fast data retrieval.


2 Answers

http://www.mapdb.org/

Also take a look at this question: Alternative to BerkeleyDB?

like image 153
cruftex Avatar answered Oct 17 '22 18:10

cruftex


Since MapDB is a possible solution for your problem, Chronicle Map is also worth consideration. It's an embeddable Java key-value store, optionally persistent, offering a very similar programming model to MapDB: it also via the vanilla java.util.Map interface and transparent serialization of keys and values.

The major difference is that according to third-party benchmarks, Chronicle Map is times faster than MapDB.

Regarding stability, no bugs were reported about the Chronicle Map data storage for months now, while it is in active use in many projects.

Disclaimer: I'm the developer of Chronicle Map.

like image 36
leventov Avatar answered Oct 17 '22 17:10

leventov