Skip to content

Commit

Permalink
doc: documents remaining methods for SegmentedLog
Browse files Browse the repository at this point in the history
Documents append_record_with_contiguous_bytes, remove_expired_segments, rotate_new_write_segment and flush
  • Loading branch information
arindas committed Mar 6, 2024
1 parent c3d2e13 commit 3c4d0ba
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/storage/commit_log/segmented_log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,16 @@ where
C: Cache<usize, ()>,
C::Error: Debug,
{
/// Rotates the current _write_ [`Segment`] to a _read_ [`Segment`], creating a new _write_
/// [`Segment`] in its place.
///
/// Closes the current _write_ [`Segment`], reopens it as a new _read_ [`Segment`] and appends
/// it the the collection of _read_ [`Segment`] instances. Next, a new _write_ [`Segment`] is
/// created for this [`SegmentedLog`] with it's `base_index` set to the `highest_index` of the
/// previous _write_ [`Segment`].
///
/// This operations is used when the _write_ [`Segment`] exceeds the confiured [`Segment`]
/// storage size limit and needs to be rotated.
pub async fn rotate_new_write_segment(&mut self) -> Result<(), LogError<S, SERP, C>> {
self.flush().await?;

Expand All @@ -1021,6 +1031,7 @@ where
Ok(())
}

/// Flushes all writes in the current _write_ [`Segment`] to persistent [`Storage`].
pub async fn flush(&mut self) -> Result<(), LogError<S, SERP, C>> {
let write_segment = take_write_segment!(self)?;

Expand All @@ -1034,6 +1045,10 @@ where
Ok(())
}

/// Removes all [`Segment`] instances that are older than the given `expiry_duration`.
///
/// Returns the total number of [`Record`] instances removed from removing the [`Segment`]
/// instances.
pub async fn remove_expired_segments(
&mut self,
expiry_duration: Duration,
Expand Down Expand Up @@ -1095,6 +1110,9 @@ where
C: Cache<usize, ()>,
C::Error: Debug,
{
/// Appends a new [`Record`] containing value bytes laid out in a contiguous fashion.
///
/// Returns the index of the newly appended [`Record`].
pub async fn append_record_with_contiguous_bytes<X>(
&mut self,
record: &Record<M, Idx, X>,
Expand Down

0 comments on commit 3c4d0ba

Please sign in to comment.