pub struct WalReader { /* private fields */ }Expand description
Read the write-ahead-log file produced by Bf-Tree.
Allows users to iterate over the log entries in the file and decide what to do with them.
Example
ⓘ
let reader = WalReader::new(&file, 4096);
for segment in reader.segment_iter() {
let seg_iter = segment.iter();
for (header, buffer) in seg_iter {
...
}
}Implementations§
Source§impl WalReader
impl WalReader
Sourcepub fn new(path: impl AsRef<Path>, segment_size: usize) -> Self
pub fn new(path: impl AsRef<Path>, segment_size: usize) -> Self
Create a new WalReader instance.
The `segment_size`` should be the same as the one used to create the WriteAheadLog instance.
Todo: we should include segment_size as a field in the wal file, so that we don’t need to pass it in.
Sourcepub fn segment_iter(&self) -> WalSegmentIter<'_>
pub fn segment_iter(&self) -> WalSegmentIter<'_>
Iterate through all the segments in the wal file.
Each segment contains multiple log entries,
you can iterate through the log entries in each segment using the iter method on WalSegment.
Auto Trait Implementations§
impl Freeze for WalReader
impl RefUnwindSafe for WalReader
impl Send for WalReader
impl Sync for WalReader
impl Unpin for WalReader
impl UnwindSafe for WalReader
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