pub struct CacheSeqPusher<P> { /* private fields */ }Expand description
Pusher wrapper that reorders out-of-order chunks into sequential order.
Buffers chunks in a BTreeMap keyed by offset. Eviction starts once the buffered
size reaches high_watermark and hands chunks to the inner pusher in ascending
offset order — across gaps if need be, so memory stays bounded while a gap is
still unfilled — until the size falls back to low_watermark. It then keeps going
for as long as the next chunk continues the one just written, so a contiguous run
is never cut in half. flush drains the whole buffer.
Implementations§
Source§impl<P: Pusher> CacheSeqPusher<P>
impl<P: Pusher> CacheSeqPusher<P>
Sourcepub const fn new(inner: P, high_watermark: usize, low_watermark: usize) -> Self
pub const fn new(inner: P, high_watermark: usize, low_watermark: usize) -> Self
Wrap inner with the given high_watermark / low_watermark (in bytes).
Eviction to the inner pusher triggers once the buffered size reaches
high_watermark, and stops once it falls back to low_watermark.
low_watermark must not exceed high_watermark. A larger low_watermark
makes high_watermark irrelevant, because eviction stops as soon as the
buffered size is at or below low_watermark, which then acts as the sole
watermark.