pub trait StorageEngine: Send + Sync {
// Required methods
fn begin_txn(&self) -> Result<TxnHandle>;
fn get(&self, txn: &TxnHandle, key: &[u8]) -> Result<Option<Row>>;
fn put(&self, txn: &TxnHandle, key: &[u8], row: Row) -> Result<()>;
fn delete(&self, txn: &TxnHandle, key: &[u8]) -> Result<()>;
fn scan(&self, txn: &TxnHandle, range: Range<Vec<u8>>) -> Result<Vec<Row>>;
fn scan_columns(
&self,
txn: &TxnHandle,
range: Range<Vec<u8>>,
cols: &[ColumnId],
) -> Result<ColumnIterator>;
fn commit(&self, txn: TxnHandle) -> Result<()>;
fn abort(&self, txn: TxnHandle) -> Result<()>;
fn stats(&self) -> StorageStats;
fn flush(&self) -> Result<()>;
fn compact(&self) -> Result<()>;
fn close(&self) -> Result<()>;
}Expand description
StorageEngine trait - the core abstraction for pluggable storage backends
Implementations:
Lscs: Columnar storage for TOON workloads (80% I/O reduction for projections)LegacyLsmTree: Row-oriented storage for compatibility
Required Methods§
Sourcefn put(&self, txn: &TxnHandle, key: &[u8], row: Row) -> Result<()>
fn put(&self, txn: &TxnHandle, key: &[u8], row: Row) -> Result<()>
Put a row (insert or update)
Sourcefn scan(&self, txn: &TxnHandle, range: Range<Vec<u8>>) -> Result<Vec<Row>>
fn scan(&self, txn: &TxnHandle, range: Range<Vec<u8>>) -> Result<Vec<Row>>
Scan a range of rows
Sourcefn scan_columns(
&self,
txn: &TxnHandle,
range: Range<Vec<u8>>,
cols: &[ColumnId],
) -> Result<ColumnIterator>
fn scan_columns( &self, txn: &TxnHandle, range: Range<Vec<u8>>, cols: &[ColumnId], ) -> Result<ColumnIterator>
Scan columns selectively (columnar optimization)
This is the key optimization for TOON workloads:
- Traditional: Read all columns O(N × K)
- Columnar: Read only selected columns O(N × k)
For k/K = 0.2, this is 80% I/O reduction
Sourcefn stats(&self) -> StorageStats
fn stats(&self) -> StorageStats
Get storage statistics