Expand description
inferadb-ledger-store: A purpose-built embedded storage engine for InferaDB.
B+ tree storage engine designed for InferaDB’s specific requirements:
- Fixed schema: All tables known at compile time (see
TableId) - Single writer: Leverages Raft’s serialization (no write-write MVCC needed)
- Raft-friendly: Optimized for append-heavy Raft log access patterns
- Checksummed pages: Crash safety with XXH3-64 verification
- Dual-slot commit: Atomic commits via shadow paging (no WAL)
§Architecture
┌─────────────────────────────────────────────┐
│ Database API │
│ (open, read, write, commit, etc.) │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ Transaction Layer │
│ (ReadTxn: snapshot, WriteTxn: COW+commit) │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ B+ Tree Layer │
│ (get, insert, delete, range, compact) │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ Page Layer │
│ (allocator, cache, checksum, COW) │
└────────────────┬────────────────────────────┘
│
┌────────────────▼────────────────────────────┐
│ Storage Backend │
│ (FileBackend / InMemoryBackend) │
└─────────────────────────────────────────────┘§Quick Start
use inferadb_ledger_store::{Database, DatabaseConfig};
use inferadb_ledger_store::tables::Entities;
// Create an in-memory database
let db = Database::open_in_memory()?;
// Write transaction
let mut txn = db.write()?;
txn.insert::<Entities>(&b"key".to_vec(), &b"value".to_vec())?;
txn.commit()?;
// Read transaction
let txn = db.read()?;
let value = txn.get::<Entities>(&b"key".to_vec())?;Re-exports§
pub use backend::DEFAULT_PAGE_SIZE;pub use backend::DatabaseHeader;pub use backend::FileBackend;pub use backend::HEADER_SIZE;pub use backend::InMemoryBackend;pub use backend::MAGIC;pub use backend::StorageBackend;pub use btree::BTree;pub use btree::CompactionStats;pub use btree::PageProvider;pub use db::Database;pub use db::DatabaseConfig;pub use db::DatabaseStats;pub use db::ReadTransaction;pub use db::TableIterator;pub use db::WriteTransaction;pub use dirty_bitmap::DirtyBitmap;pub use error::Error;pub use error::PageId;pub use error::PageType;pub use error::Result;pub use integrity::IntegrityScrubber;pub use integrity::ScrubError;pub use integrity::ScrubResult;pub use page::PAGE_HEADER_SIZE;pub use page::Page;pub use page::PageAllocator;pub use page::PageCache;pub use tables::Table;pub use tables::TableEntry;pub use tables::TableId;pub use types::Key;pub use types::KeyType;pub use types::Value;
Modules§
- backend
- Storage backend abstraction (file-based and in-memory implementations). Storage backend abstraction for the store engine.
- btree
- B+ tree index structure with get, insert, delete, range, and compaction operations. B+ tree implementation for the store engine.
- crypto
- Envelope encryption for data at rest (AES-256-GCM + AES-KWP). Envelope encryption for data at rest.
- db
- Database API: open, read, write, commit, and iteration. Database and transaction management for inferadb-ledger-store.
- dirty_
bitmap - Bitmap for tracking pages modified since the last backup checkpoint. Dirty page bitmap for incremental backup tracking.
- error
- Error types and result aliases for the store crate. Error types for the store engine.
- integrity
- Integrity scrubbing for detecting page-level corruption. Integrity scrubber for detecting silent data corruption.
- page
- Page management: allocation, caching, checksums, and copy-on-write. Page management for the store engine.
- tables
- Compile-time table definitions mapping logical tables to B+ tree instances. Fixed table definitions for the store engine.
- transaction
- Transaction tracking and snapshot management for copy-on-write semantics. Transaction tracking and snapshot management for Copy-on-Write semantics.
- types
- Key and value type definitions used across the storage engine. Key and value type encoding for the store engine.
Constants§
- VERSION
- Crate API version. For on-disk format version, see
backend::FORMAT_VERSION.