pub struct CheckpointBatcher { /* private fields */ }Expand description
Accumulates state blobs and flushes them as a single compressed object.
Call add for each partition/operator state blob during a
checkpoint cycle, then flush at the end.
should_flush returns true when the buffer exceeds
the configured threshold.
Implementations§
Source§impl CheckpointBatcher
impl CheckpointBatcher
Sourcepub fn new(
store: Arc<dyn ObjectStore>,
prefix: String,
flush_threshold: Option<usize>,
) -> Result<Self>
pub fn new( store: Arc<dyn ObjectStore>, prefix: String, flush_threshold: Option<usize>, ) -> Result<Self>
Create a new batcher.
prefix is prepended to all object paths (e.g., "nodes/abc123/").
flush_threshold is the uncompressed buffer size that triggers a flush
(default: 8 MB).
§Errors
Returns std::io::Error if the internal Tokio runtime cannot be created.
Sourcepub fn add(&mut self, key: String, data: Vec<u8>)
pub fn add(&mut self, key: String, data: Vec<u8>)
Add a state blob to the buffer.
The key identifies the partition/operator (e.g., "partition-0/agg").
Call should_flush after adding to check whether
the buffer exceeds the threshold.
Sourcepub fn should_flush(&self) -> bool
pub fn should_flush(&self) -> bool
Returns true if the buffer exceeds the flush threshold.
Sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Returns the current uncompressed buffer size in bytes.
Sourcepub fn metrics(&self) -> &Arc<BatchMetrics>
pub fn metrics(&self) -> &Arc<BatchMetrics>
Shared metrics handle.
Sourcepub fn flush(&mut self, epoch: u64) -> Result<(), CheckpointStoreError>
pub fn flush(&mut self, epoch: u64) -> Result<(), CheckpointStoreError>
Flush buffered entries as a single LZ4-compressed object.
The object is written to {prefix}checkpoints/batch-{epoch:06}.lz4.
After a successful flush the buffer is cleared.
Does nothing if the buffer is empty.
§Errors
Returns CheckpointStoreError on serialization or object store failure.
Auto Trait Implementations§
impl !Freeze for CheckpointBatcher
impl !RefUnwindSafe for CheckpointBatcher
impl Send for CheckpointBatcher
impl Sync for CheckpointBatcher
impl Unpin for CheckpointBatcher
impl UnsafeUnpin for CheckpointBatcher
impl !UnwindSafe for CheckpointBatcher
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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