pub struct ChunkProducer<'a> { /* private fields */ }Expand description
Page-aligned chunk producer. The producer accumulates byte-encoded rows in an N × 16 KiB buffer; on the first of byte / row / latency cap it forwards the buffer to the supplied flush closure, which the transport layer turns into a chunked-encoding frame.
The struct does not know about HTTP, NDJSON, or chunked transfer — it is wire-agnostic so the gRPC and RedWire paths can reuse it.
Implementations§
Source§impl<'a> ChunkProducer<'a>
impl<'a> ChunkProducer<'a>
pub fn new(config: &StreamConfig, clock: &'a dyn Clock) -> Self
Sourcepub fn push_line<F>(&mut self, line: &[u8], flush: &mut F) -> Result<bool>
pub fn push_line<F>(&mut self, line: &[u8], flush: &mut F) -> Result<bool>
Append one already-encoded line (NDJSON: bytes + \n). Returns
true if the append triggered a flush.
Sourcepub fn drive_lines<S, R, Enc, F>(
&mut self,
source: S,
encode: Enc,
flush: &mut F,
) -> Result<u64>
pub fn drive_lines<S, R, Enc, F>( &mut self, source: S, encode: Enc, flush: &mut F, ) -> Result<u64>
Issue #768 / S9 — drive a pull-based line source into the
production buffer. The producer pulls one encoded line at a
time from source and routes it through push_line, so the
resident working set is the page-aligned buffer plus the single
line currently in hand — never the full result set. Pair this
with the pull-based scan iterators
(parallel_scan::parallel_scan_rows,
bitmap_scan::execute_bitmap_scan_stream) whose records are
encoded lazily by encode.
Returns the number of lines consumed. Flush caps (byte / row /
latency) fire mid-drain exactly as they would for hand-driven
push_line calls, so first-line latency stays bounded by
chunk.max_latency_ms regardless of how many lines the source
will ultimately yield.
Sourcepub fn finish<F>(&mut self, flush: &mut F) -> Result<()>
pub fn finish<F>(&mut self, flush: &mut F) -> Result<()>
Force-flush any buffered bytes — used after the final NDJSON line
({"end": …}) to push the tail of the buffer before closing the
connection.
pub fn total_flushes(&self) -> u64
pub fn total_bytes(&self) -> u64
pub fn total_rows(&self) -> u64
pub fn last_flush_reason(&self) -> Option<FlushReason>
Auto Trait Implementations§
impl<'a> Freeze for ChunkProducer<'a>
impl<'a> !RefUnwindSafe for ChunkProducer<'a>
impl<'a> Send for ChunkProducer<'a>
impl<'a> Sync for ChunkProducer<'a>
impl<'a> Unpin for ChunkProducer<'a>
impl<'a> UnsafeUnpin for ChunkProducer<'a>
impl<'a> !UnwindSafe for ChunkProducer<'a>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request