pub struct CacheMergePusher<P> { /* private fields */ }Expand description
Pusher wrapper that buffers chunks and merges each flush run into a single Bytes.
Out-of-order chunks are stored in a BTreeMap. When a contiguous run reaches
the high watermark, all chunks in that run are coalesced into one contiguous
BytesMut before being pushed. This minimizes write calls to the inner pusher
at the cost of an extra memory copy.
Implementations§
Source§impl<P: Pusher> CacheMergePusher<P>
impl<P: Pusher> CacheMergePusher<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 does nothing until the
buffered size passes low_watermark, which then acts as the sole watermark.
With high_watermark == low_watermark, a push that lands the buffered size
exactly on the watermark evicts nothing; the next push takes it above and
eviction proceeds as usual.