Expand description
Embeddable batched write path with structured partial-failure reporting.
This is the write counterpart to the streaming read cursor: a host
embedding ferrule-sql as an output sink pushes rows in and gets
back a structured WriteReport describing exactly which batches /
rows landed and which were rejected, so it can route the rejects.
Reuse, not reinvention. Every byte of SQL this module emits comes
from the existing copy/load machinery — build_insert_sql and the
per-dialect conflict (ON CONFLICT / MERGE / ODKU) builders, the
insert_batch bulk-vs-generic dispatcher, quote_identifier,
render_value, and the
transaction helpers. The write path only adds
batching, back-pressure, the atomic-boundary policy, and the
structured result.
Bounded, back-pressured batches. Rows are consumed from any
iterator and flushed in fixed-size batches
(WriteOptions::batch_size); only one batch is buffered at a time,
so peak memory is O(batch_size) regardless of how many rows the
source iterator yields. Pair this with the streaming
RowCursor on the read side for an end-to-end
bounded-memory pipe.
Structs§
- Rejected
Batch - A batch that failed to write as a unit.
- Rejected
Row - A single row rejected during a
WriteOptions::isolate_failuresprobe.row_indexis the 0-based index within the whole write. - Write
Options - Configuration for a batched write.
- Write
Report - Structured outcome of a batched write.
Enums§
- Batch
Outcome - What happened to one batch.
- Write
Mode - Host-facing conflict semantics for a batched write.
Constants§
- DEFAULT_
WRITE_ BATCH - Default rows per write batch. Caps the in-flight buffer so a write of
an unbounded row stream stays
O(batch_size)in memory.
Functions§
- write_
rows - Write
rowsintotableondstin bounded back-pressured batches, returning a structuredWriteReport.