Skip to main content

StorageExtension

Trait StorageExtension 

Source
pub trait StorageExtension: Extension {
    // Required methods
    fn get(
        &self,
        table_id: TableId,
        key: &[u8],
    ) -> KernelResult<Option<Vec<u8>>>;
    fn put(
        &self,
        table_id: TableId,
        key: &[u8],
        value: &[u8],
        txn_id: TransactionId,
    ) -> KernelResult<()>;
    fn delete(
        &self,
        table_id: TableId,
        key: &[u8],
        txn_id: TransactionId,
    ) -> KernelResult<()>;
    fn scan(
        &self,
        table_id: TableId,
        start: &[u8],
        end: &[u8],
        limit: usize,
    ) -> KernelResult<Vec<(Vec<u8>, Vec<u8>)>>;
    fn flush(&self) -> KernelResult<()>;

    // Provided methods
    fn compact(&self) -> KernelResult<()> { ... }
    fn stats(&self) -> StorageStats { ... }
}
Expand description

Storage backend extension

Implement this to provide alternative storage engines (LSCS, RocksDB, etc.)

Required Methods§

Source

fn get(&self, table_id: TableId, key: &[u8]) -> KernelResult<Option<Vec<u8>>>

Read data for a key

Source

fn put( &self, table_id: TableId, key: &[u8], value: &[u8], txn_id: TransactionId, ) -> KernelResult<()>

Write data for a key

Source

fn delete( &self, table_id: TableId, key: &[u8], txn_id: TransactionId, ) -> KernelResult<()>

Delete a key

Source

fn scan( &self, table_id: TableId, start: &[u8], end: &[u8], limit: usize, ) -> KernelResult<Vec<(Vec<u8>, Vec<u8>)>>

Scan a range of keys

Source

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

Flush pending writes

Provided Methods§

Source

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

Compact storage (if applicable)

Source

fn stats(&self) -> StorageStats

Get storage statistics

Implementors§