pub struct WALWriter { /* private fields */ }Expand description
WAL writer for appending records to WAL file
Handles writing WAL records to disk with proper synchronization for crash recovery. Records are written in format:
[4 bytes: record size (little-endian u32)]
[N bytes: serialized record]§Durability
Each record is followed by an optional fsync for durability. For performance, multiple records can be batched before syncing.
Implementations§
Source§impl WALWriter
impl WALWriter
Sourcepub fn new(wal_path: PathBuf, start_lsn: u64) -> NativeResult<Self>
pub fn new(wal_path: PathBuf, start_lsn: u64) -> NativeResult<Self>
Sourcepub fn current_lsn(&self) -> u64
pub fn current_lsn(&self) -> u64
Get current LSN
Sourcepub fn committed_lsn(&self) -> u64
pub fn committed_lsn(&self) -> u64
Get committed LSN
Sourcepub fn write_header(&self) -> NativeResult<()>
pub fn write_header(&self) -> NativeResult<()>
Write WAL header (initializes new WAL file)
Sourcepub fn append(&mut self, record: &V3WALRecord) -> NativeResult<()>
pub fn append(&mut self, record: &V3WALRecord) -> NativeResult<()>
Append a record to WAL buffer
Record is buffered until flush() is called or buffer threshold is reached.
Sourcepub fn flush(&mut self) -> NativeResult<()>
pub fn flush(&mut self) -> NativeResult<()>
Flush buffered records to disk
Writes all buffered records and optionally syncs to disk.
Sourcepub fn commit(&mut self) -> NativeResult<()>
pub fn commit(&mut self) -> NativeResult<()>
Mark records up to current LSN as committed
Updates the committed_lsn in WAL header. Requires flush to persist the updated header.
Sourcepub fn truncate(&self) -> NativeResult<()>
pub fn truncate(&self) -> NativeResult<()>
Truncate WAL file (after checkpoint)
Removes WAL records that are no longer needed.
Sourcepub fn page_allocate(&mut self, page_id: u64) -> NativeResult<u64>
pub fn page_allocate(&mut self, page_id: u64) -> NativeResult<u64>
Write page allocate record
Sourcepub fn page_free(&mut self, page_id: u64, checksum: u32) -> NativeResult<u64>
pub fn page_free(&mut self, page_id: u64, checksum: u32) -> NativeResult<u64>
Write page free record
Sourcepub fn page_write(
&mut self,
page_id: u64,
offset: u32,
data: Vec<u8>,
) -> NativeResult<u64>
pub fn page_write( &mut self, page_id: u64, offset: u32, data: Vec<u8>, ) -> NativeResult<u64>
Write page write record
Sourcepub fn btree_split(
&mut self,
original_page_id: u64,
new_page_id: u64,
split_key: u64,
page_type: bool,
) -> NativeResult<u64>
pub fn btree_split( &mut self, original_page_id: u64, new_page_id: u64, split_key: u64, page_type: bool, ) -> NativeResult<u64>
Write B+Tree split record
Sourcepub fn checkpoint(
&mut self,
root_page_id: u64,
total_pages: u64,
btree_height: u32,
free_page_list_head: u64,
header: &PersistentHeaderV3,
) -> NativeResult<u64>
pub fn checkpoint( &mut self, root_page_id: u64, total_pages: u64, btree_height: u32, free_page_list_head: u64, header: &PersistentHeaderV3, ) -> NativeResult<u64>
Write checkpoint record
Sourcepub fn transaction_begin(&mut self, tx_id: u64) -> NativeResult<u64>
pub fn transaction_begin(&mut self, tx_id: u64) -> NativeResult<u64>
Write transaction begin record
Sourcepub fn transaction_commit(&mut self, tx_id: u64) -> NativeResult<u64>
pub fn transaction_commit(&mut self, tx_id: u64) -> NativeResult<u64>
Write transaction commit record
Sourcepub fn transaction_rollback(&mut self, tx_id: u64) -> NativeResult<u64>
pub fn transaction_rollback(&mut self, tx_id: u64) -> NativeResult<u64>
Write transaction rollback record
Sourcepub fn edge_insert(
&mut self,
src: i64,
dst: i64,
direction: u8,
page_id: u64,
) -> NativeResult<u64>
pub fn edge_insert( &mut self, src: i64, dst: i64, direction: u8, page_id: u64, ) -> NativeResult<u64>
Write edge insert record
Records an edge insertion for WAL replay during crash recovery. The edge will be inserted into the edge cluster during recovery.
Sourcepub fn set_flush_threshold(&mut self, threshold: usize)
pub fn set_flush_threshold(&mut self, threshold: usize)
Set buffer flush threshold
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WALWriter
impl RefUnwindSafe for WALWriter
impl Send for WALWriter
impl Sync for WALWriter
impl Unpin for WALWriter
impl UnsafeUnpin for WALWriter
impl UnwindSafe for WALWriter
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
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>
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>
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