A simple key-value database implementation using Log-Structured Merge (LSM) tree in Python.
- In-memory MemTable for fast writes
- Write-Ahead Log (WAL) for durability
- Sorted String Tables (SSTables) for persistent storage
- Basic compaction support
- Thread-safe operations
The database consists of several components:
- MemTable: An in-memory table that stores recent writes
- WAL: Write-Ahead Log for durability
- SSTable: Sorted String Tables for persistent storage
- Compaction: Merges SSTables to maintain performance
-
Clone the repository:
git clone https://github.com/Jyo561/LSM-DB.git cd LSM-DB
-
Run the project:
python3 main.py
The CLI supports the following commands:
put <key> <value>
- Store a key-value pairget <key>
- Retrieve a value by keydelete <key>
- Remove a key-value pairexit
- Exit the CLI
- Uses a map for O(1) lookups
- Tracks size for flush triggers
- Thread-safe with mutex
- Binary format with length-prefixed records
- Appends-only for durability
- Used for recovery
- Sorted key-value pairs
- Index for fast lookups
- Binary format with length-prefixed records
Contributions are welcome! Please feel free to submit a Pull Request.