Single-file, persistent, sorted keystore for Java (alternative to Berkeley DB)

Berkeley DB Licensing (JE) can be a bargain killer. I have a Java application for a small set of clients, but since it is a desktop application, my price cannot support licensing of individual instances.

Is there a recommended Java alternative to Berkeley DB? Commercial or other (good implementations of the key value storage can become non-trivial, I prefer to postpone maintenance elsewhere). I need more than just a hash store, since I will need to iterate through subsequent subsets of keys, and the main hash stores will be O (m * n), which they will look for, and I expect the storage to be ~ 50-60GiB on the desktop the car. Added benefit that you can recommend to keep its backup storage in a single file?

+6
java key-value-store berkeley-db
source share
10 answers

You should try JDBM2 , it does what you want:

  • A disk with HashMaps / TreeMaps support, so you can iterate through the keys.
  • Apache 2 License

Moreover:

  • Fast, very small size.
  • transactional
  • An autonomous bank has only 145 KB.
  • Simple use
  • Scales to 1e9 records
  • Uses Java serialization, does not display ORM

UPDATE

The project has now turned into MapDB http://www.mapdb.org

+9
source share

I think SQLite is exactly what you want: Public Domain, Single File Database, Zero-Configuration, Small Footprint, Fast, Cross-Platform, etc. Here is a list of wrappers ; there is a section for Java. Take a look at sqlite4java and read more on Java + SQLite here .

+5
source share

It will not be a single file, but if you want a built-in database, I suggest Java DB (a rebranded version of Apache Derby , which I used in my previous work with great results).

Plus, both are completely free.

Edit: reading other comments, another note: Java DB / Derby is 100% Java.

+3
source share

--- Edited after viewing file size ---

50 to 60 gigabytes of files! It seems that you will need to know that your database engine did not load all this into memory immediately, and was very efficient in processing / deleting unloaded data backup blocks.

I don’t know if Cloudscape is suitable for the task, and I won’t be surprised if this is not so.

--- The original message follows ---

Cloudscape is often suitable for counting. It's a bit bigger than the Berkeley DB, but it got enough grip to distribute even with some JDK offers.

+2
source share

Consider ehcache. I am showing a class here to package it as java.util.Map. You can easily store lists or other data structures as your values, avoiding the O (m * n) problem you're worried about. ehcache is an Apache 2.0 license with a commercial version available from Terracotta. The open source version will allow you to flip the cache to disk, and if you decide not to leave the cache entries, this is actually a permanent keystore.

+2
source share

JavaDB aka Derby aka Cloudscape would be a decent choice; it is a pure Java SQL database, and it is included in the JRE, so you do not need to send it with code or require the user to install separately.

(It is not actually included in the JRE provided by some Linux package managers, but there will be a separate package that is trivial to install)

However, Derby has a rather poor performance. An alternative would be H2 - again, a clean Java SQL database that stores the database in a single file, with a jar of ~ 1 MB in size under a redistributable license , but much faster and easier than Derby .

I enjoyed using H2 for a number of small projects. JBoss liked that they tied it up in AS7 . It's trivial to set up, and definitely worth a try.

+2
source share

Persistit is a new rival. It is a fast, persistent, and transactional Java B + Tree library.

I am afraid that there is no guarantee that it will be preserved anyway. Akiban, a company supporting Persistit, was recently acquired by FoundationDB. The latter did not provide any information about the future.

https://github.com/akiban/persistit

+2
source share

I just would like to point out that the backend for storing H2 can also be used as a mechanism for storing key values ​​if you do not need sql / jdbc:

http://www.h2database.com/html/mvstore.html

+1
source share

H2 http://www.h2database.com/

It is a full-blown SQL / JDBC database, but it is lightweight and fast.

0
source share

See LMDBJava , Java bindings to LMDB , the fastest sorted ACID key-value-key there.

0
source share

All Articles