Struct LogWriter
pub struct LogWriter { /* private fields */ }Expand description
Appends records to a shard log in memory. Assigns LSNs, interns names per segment and decides segment boundaries. Pure: no files.
Implementations§
§impl LogWriter
impl LogWriter
pub fn new(
shard: u32,
segment: u64,
next_lsn: Lsn,
segment_bytes: u64,
now_ms: u64,
) -> Self
pub fn new( shard: u32, segment: u64, next_lsn: Lsn, segment_bytes: u64, now_ms: u64, ) -> Self
Starts a new segment segment whose first record will be next_lsn.
pub fn next_lsn(&self) -> Lsn
pub fn last_lsn(&self) -> Lsn
pub fn segment(&self) -> u64
pub fn segment_bytes(&self) -> u64
pub fn limit_first_segment(&mut self, bytes: u64)
pub fn limit_first_segment(&mut self, bytes: u64)
The segment opened at recovery may be smaller. Later segments retain their configured capacity and the maximum record size is unchanged.
pub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Whether records or a new segment’s header wait for a flush. The header of the segment an open starts is flushed on its own: replicated mode anchors a checkpoint on the batch that ends at the checkpoint’s position, which must lie in a segment the checkpoint keeps. A header alone holds no record, so the next open may replace that segment.
pub fn pending_records(&self) -> u32
pub fn append<S: AsRef<str>, B: AsRef<[u8]>>(
&mut self,
rec: &Record<S, B>,
now_ms: u64,
) -> Result<Lsn, TooLarge>
pub fn append<S: AsRef<str>, B: AsRef<[u8]>>( &mut self, rec: &Record<S, B>, now_ms: u64, ) -> Result<Lsn, TooLarge>
Appends one record and returns its LSN.
pub fn segment_first_lsn(&self, segment: u64) -> Option<Lsn>
pub fn segment_first_lsn(&self, segment: u64) -> Option<Lsn>
First LSN of each segment written by this writer.