Simple, fast Key-Value storage. Inspired by HaloDB

Overview

Phantom

GitHub Total Alerts Code Quality: Java

Introduction

Phantom is an embedded key-value store, provides extreme high write throughput while maintains low latency data access.

Phantom was inspired by HaloDB, the name "Phantom" (belongs to the darkness) was derived from the name "Halo" (belongs to the light) from HaloDB.

The design principles of Phantom is old and simple. It uses log-structured data files and hash index (like HaloDB) to achieve the high write workload yet still maintain low latency access with the cost of no range scan support.

Usage

Installation (PRE-RELEASE version)

Add dependency to pom.xml (Maven)

<dependency>
    <groupId>io.github.tuannh982</groupId>
    <artifactId>phantom</artifactId>
</dependency>

or build.gralde (Gradle)

implementation 'io.github.tuannh982:phantom:+'

Create DB instance

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()
);

Basic operations

get

byte[] key = new byte[] {...};
GetResult result = db.get(key); 
byte[] read = result.getValue();

put

byte[] key = new byte[] {...};
byte[] value = new byte[] {...};
ModifyResult result = db.put(key, value);
boolean success = result.isSuccess();

putIfAbsent

byte[] key = new byte[] {...};
byte[] value = new byte[] {...};
ModifyResult result = db.putIfAbsent(key, value);
boolean success = result.isSuccess();

replace

byte[] key = new byte[] {...};
byte[] value = new byte[] {...};
ModifyResult result = db.replace(key, value);
boolean success = result.isSuccess();

delete

byte[] key = new byte[] {...};
ModifyResult result = db.delete(key, value);
boolean success = result.isSuccess();

advanced write operation

byte[] key = new byte[] {...};
WriteOps ops = WriteOps.PUT;
WritePolicy policy = WritePolicy.builder()
        .sequenceNumberPolicy(WritePolicy.SequenceNumberPolicy.NONE)
        .recordExistsAction(WritePolicy.RecordExistsAction.CREATE_ONLY)
        .build();
ModifyResult result = db.write(ops, policy, key, value);
boolean success = result.isSuccess();

Close DB instance

db.close();

Notes

This project still in development, so there are lots of bugs exist. Please don't use the pre-release version as they contain a lot of bugs, use directly from master branch since it's always up-to-date and maybe contains bug fixed.

TODOs

  • Testing
    • Unit test
    • Performance test
    • Benchmark report
  • Guide
    • Tuning guide
    • Development guide
  • Support distributed mode
    • WAL (in consideration)
    • Replication manager
You might also like...

Replicate your Key Value Store across your network, with consistency, persistance and performance.

Chronicle Map Version Overview Chronicle Map is a super-fast, in-memory, non-blocking, key-value store, designed for low-latency, and/or multi-process

Dec 29, 2022

Replicate your Key Value Store across your network, with consistency, persistance and performance.

Chronicle Map Version Overview Chronicle Map is a super-fast, in-memory, non-blocking, key-value store, designed for low-latency, and/or multi-process

Dec 29, 2022

Lightning Memory Database (LMDB) for Java: a low latency, transactional, sorted, embedded, key-value store

Lightning Memory Database (LMDB) for Java: a low latency, transactional, sorted, embedded, key-value store

LMDB for Java LMDB offers: Transactions (full ACID semantics) Ordered keys (enabling very fast cursor-based iteration) Memory-mapped files (enabling o

Dec 23, 2022

Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally.

Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally.

Memo Android processing and secured library for managing SharedPreferences as key-value elements efficiently and structurally. 1. Depend on our librar

Jun 30, 2022

Facsimile - Copy Your Most Used Text to Clipboard Easily with Facsimile!. It Helps You to Store You Most Used Text as a Key, Value Pair and Copy it to Clipboard with a Shortcut.

Facsimile - Copy Your Most Used Text to Clipboard Easily with Facsimile!. It Helps You to Store You Most Used Text as a Key, Value Pair and Copy it to Clipboard with a Shortcut.

Facsimile An exact copy of Your Information ! Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Installation

Sep 12, 2022

A cloud-native, serverless, scalable, cheap key-value store

Sleeper Introduction Sleeper is a serverless, cloud-native, log-structured merge tree based, scalable key-value store. It is designed to allow the ing

Dec 26, 2022

SecureDB is an extension for Ai2 Appinventor and its distros which stores the data in the form of key and value just like TinyDB but in a more secure manner.

SecureDB is an extension for Ai2 Appinventor and its distros which stores the data in the form of key and value just like TinyDB but in a more secure manner.

SecureDB SecureDB is an extension for Ai2 Appinventor and its distros which stores data for your app in a secure format locally on user's device. Expl

Sep 24, 2022

A Slimefun4 addon that adds a new storage solution for mass and organised storage without harsh performance.

A Slimefun4 addon that adds a new storage solution for mass and organised storage without harsh performance.

Networks is a Slimefun4 addon that brings a simple yet powerful item storage and movement network that works along side cargo. Network Grid / Crafting

Jan 7, 2023

Storm - a fast, easy to use, no-bullshit opinionated Java ORM inspired by Doctrine

Storm - a fast, easy to use, no-bullshit opinionated Java ORM inspired by Doctrine

A stupidly simple Java/MySQL ORM with native Hikaricp and Redis cache support supporting MariaDB and Sqlite

Dec 1, 2022

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.

MapDB: database engine MapDB combines embedded database engine and Java collections. It is free under Apache 2 license. MapDB is flexible and can be u

Dec 30, 2022

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.

MapDB: database engine MapDB combines embedded database engine and Java collections. It is free under Apache 2 license. MapDB is flexible and can be u

Jan 1, 2023

Simple and extensible storage service implementation with optional encryption.

Simple and extensible storage service implementation with optional encryption.

Simple and extensible storage service implementation with optional encryption. About Hole Hole is a simple data storage made with a soul for those who

Aug 13, 2022

A simple-to-use storage ORM supporting several databases for Java.

Storage Handler This is a library based off of my old storage handler within my queue revamp. It's for easy storage handling for multiple platforms. N

Jun 22, 2022

Fast and Easy mapping from database and csv to POJO. A java micro ORM, lightweight alternative to iBatis and Hibernate. Fast Csv Parser and Csv Mapper

Simple Flat Mapper Release Notes Getting Started Docs Building it The build is using Maven. git clone https://github.com/arnaudroger/SimpleFlatMapper.

Dec 17, 2022

Annotation processor to create immutable objects and builders. Feels like Guava's immutable collections but for regular value objects. JSON, Jackson, Gson, JAX-RS integrations included

Read full documentation at http://immutables.org // Define abstract value type using interface, abstract class or annotation @Value.Immutable public i

Dec 31, 2022

Adds value to towns, by giving each one a unique set of automatically-generated resources.

TownyResources TownyResources adds value to towns, by giving each one a unique set of automatically-produced resources which can be collected by playe

Dec 30, 2022

SpringBoot based return value types are supported by browsers

SpringBoot based return value types are supported by browsers

Jun 24, 2022

Jacksum (JAva ChecKSUM) is a free, open source, cross-platform, feature-rich, multi-threaded command line tool for calculating hash values, verifying data integrity, finding files by their fingerprints, and finding algorithms to a hash value.

Jacksum (JAva ChecKSUM) is a free, open source, cross-platform, feature-rich, multi-threaded command line tool for calculating hash values, verifying data integrity, finding files by their fingerprints, and finding algorithms to a hash value.

Dec 26, 2022
Comments
  • Bump log4j-api from 2.13.3 to 2.17.1

    Bump log4j-api from 2.13.3 to 2.17.1

    Bumps log4j-api from 2.13.3 to 2.17.1.

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump log4j-core from 2.13.3 to 2.17.1

    Bump log4j-core from 2.13.3 to 2.17.1

    Bumps log4j-core from 2.13.3 to 2.17.1.

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v0.1.2)
Owner
Zzz
null
Replicate your Key Value Store across your network, with consistency, persistance and performance.

Chronicle Map Version Overview Chronicle Map is a super-fast, in-memory, non-blocking, key-value store, designed for low-latency, and/or multi-process

Chronicle Software : Open Source 2.5k Dec 29, 2022
Lightning Memory Database (LMDB) for Java: a low latency, transactional, sorted, embedded, key-value store

LMDB for Java LMDB offers: Transactions (full ACID semantics) Ordered keys (enabling very fast cursor-based iteration) Memory-mapped files (enabling o

null 680 Dec 23, 2022
RTree2D is a 2D immutable R-tree with STR (Sort-Tile-Recursive) packing for ultra-fast nearest and intersection queries

RTree2D RTree2D is a 2D immutable R-tree with STR (Sort-Tile-Recursive) packing for ultra-fast nearest and intersection queries. Goals Main our requir

Andriy Plokhotnyuk 121 Dec 14, 2022
A fast object pool for the JVM

Stormpot Stormpot is an object pooling library for Java. Use it to recycle objects that are expensive to create. The library will take care of creatin

Chris Vest 302 Nov 14, 2022
Fast integer compression in C using the StreamVByte codec

streamvbyte StreamVByte is a new integer compression technique that applies SIMD instructions (vectorization) to Google's Group Varint approach. The n

Daniel Lemire 281 Dec 27, 2022
Fast campus 강의 '현실 세상의 TDD' 실습에 사용된 예제 코드를 제공합니다.

현실 세상의 TDD 실습 코드 Fast campus 강의 '현실 세상의 TDD' 실습에 사용된 예제 코드를 제공합니다. 예제 코드는 강의 촬영 전에 미리 준비되었고 강의 촬영 시 라이브 코딩이 진행되었기 때문에 세부 코드는 강의 영상에서 보는 것과 다를 수 있습니다.

Gyuwon Yi 170 Jan 2, 2023
A simple integer compression library in Java

JavaFastPFOR: A simple integer compression library in Java License This code is released under the Apache License Version 2.0 http://www.apache.org/li

Daniel Lemire 487 Dec 30, 2022
Simple Binary Encoding (SBE) - High Performance Message Codec

Simple Binary Encoding (SBE) SBE is an OSI layer 6 presentation for encoding and decoding binary application messages for low-latency financial applic

Real Logic 2.8k Dec 28, 2022
FastKV is an efficient and reliable key-value storage component written with Java.

FastKV 中文文档 FastKV is an efficient and reliable key-value storage component written with Java. It can be used on platforms with JVM environment, such

Billy Wei 274 Dec 28, 2022
Immutable key/value store with efficient space utilization and fast reads. They are ideal for the use-case of tables built by batch processes and shipped to multiple servers.

Minimal Perfect Hash Tables About Minimal Perfect Hash Tables are an immutable key/value store with efficient space utilization and fast reads. They a

Indeed Engineering 92 Nov 22, 2022