Phantom is an embedded key-value store designed for extreme write throughput while ensuring low latency data access. With its straightforward design and reliance on log-structured data files and hash indexing, it offers a performant solution for applications that require efficient data handling without the complexity of range scan support.
Phantom: A High-Performance Key-Value Store
Phantom is a cutting-edge embedded key-value storage solution that offers exceptionally high write throughput while ensuring low-latency data access. Inspired by HaloDB, Phantom harnesses the power of log-structured data files and hash indexes to deliver reliable performance, albeit without support for range scans.
To set up Phantom, simply add the dependency to your Maven or Gradle project. Here’s how to include it in your build files:
Maven:
<dependency>
<groupId>io.github.tuannh982</groupId>
<artifactId>phantom</artifactId>
</dependency>
Gradle:
implementation 'io.github.tuannh982:phantom:+'
Setting up a new database instance is straightforward:
String path = "/path/to/your/db/dir";
DB db = new PhantomDB(
new File(path),
PhantomDBOptions.builder()
.numberOfIndexingThread(2 * Runtime.getRuntime().availableProcessors())
.compactionThreshold(0.5f)
.dataFlushThreshold(8 * 1024 * 1024)
.maxKeySize(8)
.maxFileSize(32 * 1024 * 1024)
.maxTombstoneFileSize(8 * 1024 * 1024)
.offHeapHashTable(true)
.estimatedMaxKeyCount(16)
.memoryChunkSize(4 * 1024 * 1024)
.build()
);
Phantom supports a variety of operations for data manipulation. Here are a few examples:
byte[] key = new byte[] {...};
GetResult result = db.get(key);
byte[] read = result.getValue();
byte[] key = new byte[] {...};
byte[] value = new byte[] {...};
ModifyResult result = db.put(key, value);
boolean success = result.isSuccess();
byte[] key = new byte[] {...};
ModifyResult result = db.delete(key);
boolean success = result.isSuccess();
Always remember to cleanly close the database instance when done:
db.close();
Currently in development, this project does contain known bugs. It is recommended to utilize the master branch for the most recent updates and bug fixes rather than the pre-release version.
Planned improvements include unit testing, performance benchmarks, and support for distributed modes to advance the capabilities of Phantom even further.
With Phantom, you can ensure robust, efficient, and scalable key-value data management suitable for modern applications.
No comments yet.
Sign in to be the first to comment.