pub struct WalStorageManager { /* private fields */ }Expand description
WAL-integrated storage manager
Coordinates writes between WAL and memtable for ACID compliance.
Implementations§
Source§impl WalStorageManager
impl WalStorageManager
Sourcepub fn new<P: AsRef<Path>, F>(wal_path: P, apply_fn: F) -> Result<Self>
pub fn new<P: AsRef<Path>, F>(wal_path: P, apply_fn: F) -> Result<Self>
Create a new WAL storage manager
Sourcepub fn write(&self, txn_id: u64, key: Vec<u8>, value: Vec<u8>) -> Result<()>
pub fn write(&self, txn_id: u64, key: Vec<u8>, value: Vec<u8>) -> Result<()>
Write within a transaction (buffered)
The write is buffered until commit. This allows rollback.
Sourcepub fn write_immediate(
&self,
txn_id: u64,
key: Vec<u8>,
value: Vec<u8>,
) -> Result<()>
pub fn write_immediate( &self, txn_id: u64, key: Vec<u8>, value: Vec<u8>, ) -> Result<()>
Write immediately to WAL (for single-statement transactions)
This is more efficient for simple writes that don’t need buffering.
Sourcepub fn commit(&self, txn_id: u64) -> Result<u64>
pub fn commit(&self, txn_id: u64) -> Result<u64>
Commit a transaction
- Write all buffered writes to WAL
- fsync WAL for durability
- Apply writes to memtable
- Remove transaction from active set
Sourcepub fn abort(&self, txn_id: u64) -> Result<()>
pub fn abort(&self, txn_id: u64) -> Result<()>
Abort a transaction
Discards all buffered writes.
Sourcepub fn recover(&self) -> Result<RecoveryStats>
pub fn recover(&self) -> Result<RecoveryStats>
Recover from WAL after crash
Replays committed transactions and applies them to storage.
Sourcepub fn checkpoint(&self) -> Result<()>
pub fn checkpoint(&self) -> Result<()>
Checkpoint: truncate WAL after flush
Called after memtable flush to SST. Safe to discard WAL entries.
Sourcepub fn current_timestamp(&self) -> u64
pub fn current_timestamp(&self) -> u64
Get current timestamp
Auto Trait Implementations§
impl !Freeze for WalStorageManager
impl !RefUnwindSafe for WalStorageManager
impl !UnwindSafe for WalStorageManager
impl Send for WalStorageManager
impl Sync for WalStorageManager
impl Unpin for WalStorageManager
impl UnsafeUnpin for WalStorageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more