LevelDB is a fast, light-weight, key value store which is developed by Google. It supports multiple platforms including C++, NodeJS and Java. Before moving into deep stuff, let’s find out how to setup LevelDB in a simple Java project and what are the things that can be done using LevelDB.
1. Setting up LevelDB
There are several Java APIs are available for LevelDB and you could use any of it according to the requirement. Here, we are going to use dain/leveldb as it provides the essential functionalities of LevelDB in a convenient API.
All you have to do is importing the following dependencies to your Maven project and you are ready to go 😄
<dependency>
<groupId>org.iq80.leveldb</groupId>
<artifactId>leveldb-api</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.iq80.leveldb</groupId>
<artifactId>leveldb</artifactId>
<version>0.9</version>
</dependency>
1.1. Initializing LevelDB Store
First, import the following classes.
import org.iq80.leveldb.DB;
import static org.iq80.leveldb.impl.Iq80DBFactory.factory;
import org.iq80.leveldb.Options;
And initialize the store as follows.
DB levelDBStore;
Options options =…