pub struct NativeEncoder<F> { /* private fields */ }Expand description
Encodes a record family’s Serialize rows into the ClickHouse Native
format. Runs on pipeline threads inside the terminal stage; buffers rows
columnar in encode and emits one block per chunk
in finish_chunk.
F is the record family: Owned<T> for plain owned row structs
(NativeEncoder::<Owned<MyRow>>::new(schema)), or a borrowed family for
zero-copy pipelines — any family whose records implement Serialize at
every lifetime encodes.
Cloning mints a fresh, empty encoder over the same schema — the terminal stage clones one per shard.
Implementations§
Source§impl<F> NativeEncoder<F>
impl<F> NativeEncoder<F>
Sourcepub fn new(schema: Arc<NativeSchema>) -> Self
pub fn new(schema: Arc<NativeSchema>) -> Self
A Native encoder for the columns described by schema.
Sourcepub fn from_row_schema(schema: &RowSchema) -> Result<Self, NativeError>
pub fn from_row_schema(schema: &RowSchema) -> Result<Self, NativeError>
Build directly from a validated RowSchema.
Trait Implementations§
Source§impl<F> Clone for NativeEncoder<F>
impl<F> Clone for NativeEncoder<F>
Source§impl<F> Debug for NativeEncoder<F>
impl<F> Debug for NativeEncoder<F>
Source§impl<F> RowEncoder<F> for NativeEncoder<F>
impl<F> RowEncoder<F> for NativeEncoder<F>
Source§fn encode<'buf>(
&mut self,
rec: &Record<F::Rec<'buf>>,
_buf: &mut BytesMut,
) -> Result<(), SinkError>
fn encode<'buf>( &mut self, rec: &Record<F::Rec<'buf>>, _buf: &mut BytesMut, ) -> Result<(), SinkError>
Append
rec’s encoding to buf. Errors are record-level and
subject to the sink stage’s ErrorPolicy — except errors of
ErrorClass::Fatal, which stop
the pipeline regardless of policy (fatal means the encoder itself
is broken, e.g. the row type cannot match the target schema; every
subsequent record would fail identically).Source§fn buffered_bytes(&self) -> usize
fn buffered_bytes(&self) -> usize
Bytes the encoder is holding internally that have not yet been
flushed to a frame. Row formats append directly in
encode and buffer nothing, so the default is 0.
Columnar formats (which must transpose a whole block before any bytes
exist) return the approximate size of the block under assembly; the
terminal stage adds this to the shard buffer length when deciding
whether to seal a chunk, so a columnar block still respects
ChunkConfig::target_bytes.Source§fn finish_chunk(&mut self, buf: &mut BytesMut) -> Result<(), SinkError>
fn finish_chunk(&mut self, buf: &mut BytesMut) -> Result<(), SinkError>
Finalize the pending chunk: flush any internally-buffered rows into
buf as exactly one complete, self-describing wire frame, leaving
the encoder empty and ready for the next chunk. Row formats already
wrote every row in encode, so the default is a
no-op. The terminal stage calls this immediately before it seals each
EncodedChunk — in steady state, on data lulls, and at drain — so a
columnar encoder’s buffered rows are never silently dropped. Read moreAuto Trait Implementations§
impl<F> Freeze for NativeEncoder<F>
impl<F> RefUnwindSafe for NativeEncoder<F>
impl<F> Send for NativeEncoder<F>
impl<F> Sync for NativeEncoder<F>
impl<F> Unpin for NativeEncoder<F>
impl<F> UnsafeUnpin for NativeEncoder<F>
impl<F> UnwindSafe for NativeEncoder<F>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more