StorageEngine

Trait StorageEngine 

Source
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§

Source

fn begin_txn(&self) -> Result<TxnHandle>

Begin a new transaction

Source

fn get(&self, txn: &TxnHandle, key: &[u8]) -> Result<Option<Row>>

Get a single row by key

Source

fn put(&self, txn: &TxnHandle, key: &[u8], row: Row) -> Result<()>

Put a row (insert or update)

Source

fn delete(&self, txn: &TxnHandle, key: &[u8]) -> Result<()>

Delete a row

Source

fn scan(&self, txn: &TxnHandle, range: Range<Vec<u8>>) -> Result<Vec<Row>>

Scan a range of rows

Source

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

Source

fn commit(&self, txn: TxnHandle) -> Result<()>

Commit a transaction

Source

fn abort(&self, txn: TxnHandle) -> Result<()>

Abort a transaction

Source

fn stats(&self) -> StorageStats

Get storage statistics

Source

fn flush(&self) -> Result<()>

Force flush memtables to disk

Source

fn compact(&self) -> Result<()>

Trigger compaction

Source

fn close(&self) -> Result<()>

Close the storage engine

Implementors§