https://github.com/jdockerty/log-structured-db-engine
Toy implementation of a Log Structured Database Engine, inspired by DDIA.
https://github.com/jdockerty/log-structured-db-engine
ddia log-structured toy-project
Last synced: about 1 year ago
JSON representation
Toy implementation of a Log Structured Database Engine, inspired by DDIA.
- Host: GitHub
- URL: https://github.com/jdockerty/log-structured-db-engine
- Owner: jdockerty
- Created: 2022-05-14T19:30:33.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-24T15:25:53.000Z (almost 4 years ago)
- Last Synced: 2025-01-23T13:29:23.569Z (over 1 year ago)
- Topics: ddia, log-structured, toy-project
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Log Structured Database Engine
A toy implementation of a log structured database engine, inspired from [Designing Data Intensive Applications](https://www.oreilly.com/library/view/designing-data-intensive-applications/9781491903063/) (DDIA) book by Martin Kleppmann.
Martin shows that you can create the world's simplest database using the follow lines of `bash`
```bash
db_set() {
echo "$1,$2" >> database
}
db_get() {
grep "^$1," database | sed -e "s/^$1,//" | tail -n 1
}
```
This is my own not-so-concise implementation in Go, used to solidify the concepts that Martin portrays. Comments are provided for explanation and understanding.
### Example
Build using `go build cmd/db.go` and then run
```bash
./db --set "1, foo"
./db --set "2, bar"
./db --get "1" # outputs 'foo'
./db --set "1, bar" # updates ID 1 to bar
./db --get "1" # outputs 'bar'
./db --disable-index --get "1" # also outputs 'bar', but with a full scan returning the latest record
```