How ngthdong/yggdrasil works
Yggdrasil is a persistent key-value storage engine. The user-facing workflow runs through the CLI into the database API, which provides key operations, transactions, batches, snapshots, scans, and maintenance. The index and page-storage layers persist data, while logging and recovery support durability. Some subsystem links are supported by declarations and documented capabilities; unsampled implementation details are not inferred.
Main entry points: database.cc Database API · b_plus_tree.cc B+Tree index · buffer_pool_manager.cc Buffer pool · free_page_manager.cc Free-page manager
Components 20
Database API
- Command interface
tools/yggdrasil-cli.cc - Database API
src/database.cc - Key operations
src/database.cc - Write batches
include/engine/write_batch.h - Point-in-time snapshots
src/snapshot.cc - Ordered scans
src/index/bptree/bptree_iterator.cc - Stats and verification
include/engine/database.h
Index and Pages
- B+Tree index
src/index/bptree/b_plus_tree.cc - B+Tree pages
src/index/bptree/bptree_leaf_page.cc - Buffer pool
src/buffer/buffer_pool_manager.cc - Page-file storage
src/storage/disk/disk_manager.cc - Free-page manager
src/storage/freespace/free_page_manager.cc
Durability
- Write-ahead log
src/log/wal_manager.cc - Log records
src/log/log_record.cc - Crash recovery
src/recovery/recovery_manager.cc - Checkpointing
src/recovery/checkpoint_manager.cc
Transactions
- Transactions
src/txn/transaction.cc - Lock manager
src/txn/lock_manager.cc - Deadlock detection
src/txn/deadlock_detector.cc
Other components
- CLI user
Connections 27
- CLI user → Command interface: issues commands
README.md - Command interface → Database API: calls API
tools/yggdrasil-cli.cc - Database API → Key operations: provides
src/database.cc - Database API → Write batches: applies
- Database API → Point-in-time snapshots: creates
- Database API → Ordered scans: opens iterators
- Database API → Stats and verification: exposes
include/engine/database.h - Database API → B+Tree index: owns
- B+Tree index → Buffer pool: fetches pages
- B+Tree index → Page-file storage: reads root metadata
- B+Tree index → Free-page manager: allocates pages
- Free-page manager → Buffer pool: fetches nodes
- Free-page manager → Page-file storage: updates free-list head
- Buffer pool → Page-file storage: reads and writes
- B+Tree index → B+Tree pages: uses page formats
- Database API → Transactions: begins transactions
- Transactions → Lock manager: acquires locks
- Database API → Lock manager: owns
- Database API → Deadlock detection: configures detector
- Database API → Write-ahead log: owns
- Write-ahead log → Log records: serializes records
- Database API → Crash recovery: runs on open
- Crash recovery → B+Tree index: replays changes
- Crash recovery → Buffer pool: flushes recovered pages
- Database API → Checkpointing: checkpoints
- Checkpointing → Buffer pool: flushes pages
- Checkpointing → Write-ahead log: records checkpoint