https://github.com/kkli08/kv-store
Key-Value Storage Database
https://github.com/kkli08/kv-store
b-tree bloom-filter c-plus-plus kv-storage-engine lsm-tree
Last synced: 11 days ago
JSON representation
Key-Value Storage Database
- Host: GitHub
- URL: https://github.com/kkli08/kv-store
- Owner: kkli08
- License: mit
- Created: 2024-08-26T15:37:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-13T02:20:33.000Z (over 1 year ago)
- Last Synced: 2025-03-16T17:24:37.443Z (10 months ago)
- Topics: b-tree, bloom-filter, c-plus-plus, kv-storage-engine, lsm-tree
- Language: C++
- Homepage: https://kkli08.github.io/VeloxDB/
- Size: 279 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## KV-Store Database

Stores key-value pairs and allows retrieval of a value based on its key.
> 2024-09-12 Restructure data storage with Protobuf.
>
> Latest KvDB Repo --> [here](https://github.com/kkli08/KvDB)
> 2024-09-09 Support Template
```c++
enum class KeyValueType { INT, LONG, DOUBLE, CHAR, STRING };
```
> 2024-08-28 Support
### Operations
**kvdb::API::Open(string db_name)**
> Initializes the database system for all database files, including SSTs and other related data.
```c++
// default memtable size = 1e4
auto MyDBDefault = new kvdb::API();
MyDB_default->Open("database name");
// set memtable size
int memtableSize = 1e3;
auto MyDBSetMemtableSize = new kvdb::API(memtableSize);
MyDBSetMemtableSize->Open("database name");
// smart pointer
int memtableSize = 1e3;
auto MyDBSetMemtableSize = std::make_unique(memtableSize);
MyDBSetMemtableSize->Open("database name");
```
**template**
**kvdb::API::Put(K key, V value)**
> Put key-value pair into the database.
```c++
auto MyDB = new kvdb::API();
MyDB->Open("database name");
MyDB->Put(1, 100);
MyDB->Put(1.5, 'A');
MyDB->Put("Hello, World", 1e8LL);
```
**kvdb::API::Get(int_64)**
> Return value by the key.
```c++
auto MyDB = new kvdb::API();
KeyValue kv;
MyDB->Open("database name");
MyDB->Put(1, 100);
MyDB->Put(1.5, 'A');
MyDB->Put("Hello, World", 1e8LL);
kv = MyDB->Get("Hello, World"); // return kv -> {key: "Hello, World", value: 1e8LL}
```
**kvdb::API::Close()**
> Close the db, move all the data in memory into disk (SSTs).
```c++
auto MyDB = new kvdb::API();
MyDB->Open("database name");
MyDB->Close();
```
**kvdb::API::Scan(KeyValue smallestKey, KeyValue largestKey)**
> Retrieves all KV-pairs in a key range in key order (key1 < key2)
```c++
auto MyDB = new kvdb::API();
set KvPairs;
MyDB->Open("database name");
KvPairs = MyDB->Scan(smallestKey, largestKey2);
```
**kvdb::API::Update()**
> Update the data.
```c++
TBA
```
**kvdb::API::Delete()**
> Delete the data.
```c++
TBA
```
### SST File Layout
> 2024-09-09
>

### UML
> 2024-09-02
>

### Dataflow Diagram

### Benchmark
| Date | Operation Type | Number of Pairs | Total Time Taken (ms) | Average Time per Operation (ms) |
|------------|----------------|-----------------|-----------------------|---------------------------------|
| 2024-09-02 | Put | 1M | 369 | N/A |
| 2024-09-02 | Get | 1M | 30529 | 0.030529 |
| 2024-09-02 | Scan | 1M out of 100M | 207 | 0.000207 |
### Supported Platforms and Compilers
| Platform | Compiler | Status |
|---------------|----------------|--|
| Ubuntu 20.04 | GCC | ✅ |
| Ubuntu 20.04 | Clang | ✅ |
| Windows | MSVC (cl) | ✅ |
| macOS | Clang | ✅ |
| macOS | GCC | ✅ |