1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! # kmb-store: Page-based B+tree projection store with MVCC
//!
//! This crate provides a persistent key-value store optimized for projection state
//! in `Kimberlite`. Key features:
//!
//! - **B+tree indexing**: Efficient point lookups and range scans
//! - **MVCC**: Multi-Version Concurrency Control for point-in-time queries
//! - **Page-based storage**: 4KB pages with CRC32 integrity checks
//! - **Crash recovery**: Superblock with applied position tracking
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────┐
//! │ ProjectionStore (public API) │
//! ├─────────────────────────────────────────────────────┤
//! │ BTree (search, insert, delete, scan with MVCC) │
//! ├─────────────────────────────────────────────────────┤
//! │ PageCache (LRU cache with page-aligned I/O) │
//! ├─────────────────────────────────────────────────────┤
//! │ Page Layer (4KB pages, CRC32, slot directory) │
//! └─────────────────────────────────────────────────────┘
//! ```
//!
//! # Usage
//!
//! ```ignore
//! use kimberlite_store::{ProjectionStore, BTreeStore, WriteBatch, WriteOp};
//! use kimberlite_types::Offset;
//!
//! // Open or create a store
//! let mut store = BTreeStore::open("data/projections")?;
//!
//! // Apply a batch of changes
//! let batch = WriteBatch::new(Offset::new(1))
//! .put(table_id, key, value)
//! .delete(table_id, other_key);
//! store.apply(batch)?;
//!
//! // Point-in-time query
//! let value = store.get_at(table_id, &key, Offset::new(1))?;
//! ```
// Public API
pub use ;
pub use StoreError;
pub use BTreeStore;
pub use ;
pub use RowVersion;
use Range;
use Bytes;
use Offset;
/// Trait for projection stores that maintain derived state from the log.
///
/// Implementations must support:
/// - Sequential batch application (log replay)
/// - Point-in-time queries via MVCC
/// - Durable persistence with crash recovery
///
/// Note: Read methods take `&mut self` because they may load pages into the cache.