{"id":24972450,"url":"https://github.com/tuannh982/phantom","last_synced_at":"2025-04-11T06:32:24.846Z","repository":{"id":45070669,"uuid":"384937268","full_name":"tuannh982/phantom","owner":"tuannh982","description":"Simple, fast Key-Value storage. Inspired by HaloDB","archived":false,"fork":false,"pushed_at":"2022-01-11T03:02:42.000Z","size":300,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T04:26:46.635Z","etag":null,"topics":["database","from-scratch","hash-indexes","java","key-value","key-value-database"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuannh982.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-11T12:01:40.000Z","updated_at":"2024-12-10T03:08:31.000Z","dependencies_parsed_at":"2022-08-24T11:20:41.388Z","dependency_job_id":null,"html_url":"https://github.com/tuannh982/phantom","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuannh982%2Fphantom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuannh982%2Fphantom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuannh982%2Fphantom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuannh982%2Fphantom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuannh982","download_url":"https://codeload.github.com/tuannh982/phantom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248355545,"owners_count":21090041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","from-scratch","hash-indexes","java","key-value","key-value-database"],"created_at":"2025-02-03T17:09:35.865Z","updated_at":"2025-04-11T06:32:24.826Z","avatar_url":"https://github.com/tuannh982.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Phantom\n======\n\n[![GitHub](https://img.shields.io/github/license/tuannh982/phantom.svg)](https://github.com/tuannh982/phantom/blob/master/LICENSE)\n[![Total Alerts](https://img.shields.io/lgtm/alerts/g/tuannh982/phantom.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/tuannh982/phantom/alerts)\n[![Code Quality: Java](https://img.shields.io/lgtm/grade/java/g/tuannh982/phantom.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/tuannh982/phantom/context:java)\n\n## Introduction\nPhantom is an embedded key-value store, provides extreme high write throughput while maintains low latency data access.\n\nPhantom was inspired by HaloDB, the name \"Phantom\" (belongs to the darkness) was derived from \nthe name \"Halo\" (belongs to the light) from HaloDB.\n\nThe design principles of Phantom is old and simple. It uses log-structured data files and hash index (like HaloDB) to \nachieve the high write workload yet still maintain low latency access with the cost of no range scan support.\n\n## Usage\n\n### Installation (PRE-RELEASE version)\n\nAdd dependency to pom.xml (Maven)\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.tuannh982\u003c/groupId\u003e\n    \u003cartifactId\u003ephantom\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\nor build.gralde (Gradle)\n\n```groovy\nimplementation 'io.github.tuannh982:phantom:+'\n```\n\n### Create DB instance\n```java\nString path = \"/path/to/your/db/dir\";\nDB db = new PhantomDB(\n       new File(path),\n       PhantomDBOptions.builder()\n               .numberOfIndexingThread(2 * Runtime.getRuntime().availableProcessors())\n               .compactionThreshold(0.5f)\n               .dataFlushThreshold(8 * 1024 * 1024)\n               .maxKeySize(8)\n               .maxFileSize(32 * 1024 * 1024)\n               .maxTombstoneFileSize(8 * 1024 * 1024)\n               .offHeapHashTable(true)\n               .estimatedMaxKeyCount(16)\n               .memoryChunkSize(4 * 1024 * 1024)\n               .build()\n);\n```\n\n### Basic operations\n#### get\n```java\nbyte[] key = new byte[] {...};\nGetResult result = db.get(key); \nbyte[] read = result.getValue();\n```\n#### put\n```java\nbyte[] key = new byte[] {...};\nbyte[] value = new byte[] {...};\nModifyResult result = db.put(key, value);\nboolean success = result.isSuccess();\n```\n#### putIfAbsent\n```java\nbyte[] key = new byte[] {...};\nbyte[] value = new byte[] {...};\nModifyResult result = db.putIfAbsent(key, value);\nboolean success = result.isSuccess();\n```\n#### replace\n```java\nbyte[] key = new byte[] {...};\nbyte[] value = new byte[] {...};\nModifyResult result = db.replace(key, value);\nboolean success = result.isSuccess();\n```\n#### delete\n```java\nbyte[] key = new byte[] {...};\nModifyResult result = db.delete(key, value);\nboolean success = result.isSuccess();\n```\n\n#### advanced write operation\n```java\nbyte[] key = new byte[] {...};\nWriteOps ops = WriteOps.PUT;\nWritePolicy policy = WritePolicy.builder()\n        .sequenceNumberPolicy(WritePolicy.SequenceNumberPolicy.NONE)\n        .recordExistsAction(WritePolicy.RecordExistsAction.CREATE_ONLY)\n        .build();\nModifyResult result = db.write(ops, policy, key, value);\nboolean success = result.isSuccess();\n```\n\n### Close DB instance\n```java\ndb.close();\n```\n\n## Notes\n\nThis project still in development, so there are lots of bugs exist.\nPlease don't use the pre-release version as they contain a lot of bugs, \nuse directly from master branch since it's always up-to-date and maybe contains bug fixed.\n\n## TODOs\n- Testing\n  - Unit test\n  - Performance test\n  - Benchmark report\n- Guide\n  - Tuning guide\n  - Development guide\n- Support distributed mode\n    - WAL (in consideration)\n    - Replication manager","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuannh982%2Fphantom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuannh982%2Fphantom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuannh982%2Fphantom/lists"}