pub struct ClickHouseEncoder<F> { /* private fields */ }Expand description
Encodes a record family’s Serialize rows into RowBinary via this
crate’s serializer. Runs inside the chain’s terminal
stage on pinned pipeline threads; sink workers ship the resulting frames
as-is.
F is the record family: use Owned<T> for plain owned row structs
(ClickHouseEncoder::<Owned<MyRow>>::new()), or a borrowed family whose
Rec<'buf> points into the payload buffer for zero-copy pipelines — any
family whose records implement Serialize at every lifetime encodes.
The row struct’s field declaration order is the wire contract — it
must match the column list configured for the sink (see the crate docs).
ClickHouseEncoder::with_schema checks that contract against the
live table’s schema on each pipeline thread’s first record.
Implementations§
Source§impl<F> ClickHouseEncoder<F>
impl<F> ClickHouseEncoder<F>
Sourcepub fn with_schema(expected: Arc<RowSchema>) -> Self
pub fn with_schema(expected: Arc<RowSchema>) -> Self
An encoder that validates the row struct against expected (the
schema returned by crate::ClickHouseSink::validate_schema) on
the first record it encodes: field names and order always, type
classes in full mode. A mismatch is an
ErrorClass::Fatal error — it stops the pipeline before any
misaligned batch is sent. Steady-state cost after the first record
is one predictable branch.
Trait Implementations§
Source§impl<F> Clone for ClickHouseEncoder<F>
impl<F> Clone for ClickHouseEncoder<F>
Source§impl<F: Debug> Debug for ClickHouseEncoder<F>
impl<F: Debug> Debug for ClickHouseEncoder<F>
Source§impl<F> Default for ClickHouseEncoder<F>
impl<F> Default for ClickHouseEncoder<F>
Source§impl<F> RowEncoder<F> for ClickHouseEncoder<F>
impl<F> RowEncoder<F> for ClickHouseEncoder<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>
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
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>
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 more