A persistent key-value storage engine based on LSM-tree architecture.
Project description
Simple Python Storage Engine
What and How?
Simple LSM-tree based implementation of a key value store in python. Implemented this after reading chapter 3 of Designing Data Intensive Applications where the author talks about different data structures powering our database, one such data structure was the LSMtree. This projects implements a:
- Write Ahead Log (For atomicity and durability)
- In memory memtable (Where writes initially go to)
- SSTables (sorted string tables) where items are sorted based on keys.
The memtable is implemented using the SortedDict library of python. This ensures that the traversal through the memtable will give the items sorted by keys. This is important to flush the memtable in sorted order to the SSTable.
The SStables are ordered by levels (L0 -> L1 -> ... ). There is a preset number of SSTables allowed within a level, after which the merging and compaction process gets applied and combines those SSTables into one and moves it to the next level.
The merging and compaction process is a simple k-way merge using a minheap, similar to the leetcode qn (merging k sorted arrays).
This project supports basic key-value operations like GET, PUT, DELETE, EXISTS, CREATE. A simple CLI based interface is implemented where users can interact with the kv store.
The writes are first pushed to the Sorted Container in the memtable (which is in memory). Once the memtable reaches a threshold size, it is flushed into a persistent SSTable, every write is recorded in the WAL as it comes, for atomicity and crash recovery.
The reading process is a bit more complicated. LSMTrees are more optimized for write workloads. When the SSTable gets created, there is an index file also created which stores keys in gaps of 10 (eg: 1st item, 10th item, 20th item etc..). This was implemented for range queries. A read request is first sent to the index file to find which range it lies in and then moves to the different SSTables. Reading is not a very easy process in LSMTrees as compared to B-Trees, which are optimized for read workloads.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lsm_storage_engine_key_value_store-0.1.2.tar.gz.
File metadata
- Download URL: lsm_storage_engine_key_value_store-0.1.2.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
850b773339b8d4d20f03098f569f71ceebaec59c4451928d7e7b8c31faf187d8
|
|
| MD5 |
64dc9b10d5cbbd8865976e0b178ced06
|
|
| BLAKE2b-256 |
94f332102df7bc52d04545b72009b96c19927354512b2d7d19991005170a5bff
|
File details
Details for the file lsm_storage_engine_key_value_store-0.1.2-py3-none-any.whl.
File metadata
- Download URL: lsm_storage_engine_key_value_store-0.1.2-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae74a8356e30ecd94cfa413d52aacfed3ae7631b599b2d2ba604ca75c3ed7b88
|
|
| MD5 |
24d65791b6f9cbfcbf0a596da8f229a5
|
|
| BLAKE2b-256 |
30deae3756f9610d60752e95385c58f7d759937824aa23b5e73fd73589e5574f
|