Key-Value Database with Java Client

I basically want to save the hash table on disk, so I can request it later. My program is written in Java. The hash table maps from row to list.

There are many stores with key values, but after a lot of research / reading, it is not clear which one is better for my purposes. Here are some things that are important to me.

  • A simple keystore that allows you to get a value with a single key.
  • A good Java client that is well documented.
  • The data set is small and there is no need for additional features. Again, I want it to be simple.

I looked at Redis and MongoDB. Both look promising, but not perfect for my purposes. Any information would be appreciated.

+2
source share
5 answers

Before giving any answers, I would start by asking why I need to store this hash table on disk, because according to your description the data set is small, and therefore I assume that it can fit into memory. If it is simple to reuse this structure after restarting the application, then you can probably use any format to save it.

Secondly, you are not giving any reason why Redis or MongoDB are not ideal. Based on your (short) 3 requirements, I would say Redis is probably the best choice:

  • good java clients
  • not only can store lists, but also supports operations on list values ​​(therefore data is not opaque)

The only reason I could have suggested that you eliminate Redis is because you are looking for stringent ACID features. If this is what you are looking for, you could take a look at BerkleyDB JE. It has been a while, and the documentation is good.

+2
source

What you are looking for is a library that supports object prevalence . These libraries are designed to easily and quickly provide collections such as APIs. Below are a few libraries that let you work with collections, but use disk storage behind the scenes.

+4
source

If your dataset is small and you want it to be EASY. why don't you serialize the hash file to a file or rdbms and upload it to your application?

How do you not want to β€œrequest” your hash? key approximation? the value of "likeness"? I don't know, it seems redundant for me to store a keystore just for the sake of it.

+3
source

Take a look at JDBM2 - http://code.google.com/p/jdbm2/

I was working on a JDBM 1 base and was impressed with what I saw in jdbm2

+2
source

A "chronic map" should be perfect, it is an embedded keystore written in pure Java, so it acts as the best option, "client" (although in fact there is no "client" or "server", you just open your database and get full access to it for reading / updating).

Chronicle map is in one file. This file can be moved around the file system and even sent to another computer with a different OS and / or architecture and remain an open chronicles database.

To create or open a data warehouse (if the database file does not exist, it is created, otherwise access to the existing warehouse):

ChronicleMap<String, List<Point>> map = ChronicleMap .of(String.class, (Class<List<Point>>) (Class) List.class) .averageKey("range") .averageValue(asList(of(0, 0), of(1, 1))) .entries(10_000) .createPersistedTo(myDatabaseFile); 

Then you can work with the created ChronicleMap object in the same way as with a simple HashMap , without worrying about serializing keys and values.

0
source

All Articles