pub struct BulkLoadRequest<'a, S>{ /* private fields */ }Expand description
A handler for a bulk insert data flow.
Implementations§
Source§impl<'a, S> BulkLoadRequest<'a, S>
impl<'a, S> BulkLoadRequest<'a, S>
Sourcepub fn columns(&self) -> impl ExactSizeIterator<Item = BulkLoadColumn<'_>>
pub fn columns(&self) -> impl ExactSizeIterator<Item = BulkLoadColumn<'_>>
Returns the destination columns used by this bulk-load request.
The returned columns are ordered exactly as send expects row values
to be encoded. The metadata is discovered during
Client::bulk_insert and filtered to updateable destination columns
before the request is created.
Sourcepub fn packet_stats(&self) -> BulkLoadPacketStats
Available on crate feature bulk-load-profile only.
pub fn packet_stats(&self) -> BulkLoadPacketStats
bulk-load-profile only.Returns packet-write statistics collected by this bulk-load request.
Sourcepub fn write_timing_stats(&self) -> BulkLoadWriteTimingStats
Available on crate feature bulk-load-profile only.
pub fn write_timing_stats(&self) -> BulkLoadWriteTimingStats
bulk-load-profile only.Returns write timing statistics collected by this bulk-load request.
Sourcepub fn stats(&self) -> BulkLoadStats
Available on crate feature bulk-load-profile only.
pub fn stats(&self) -> BulkLoadStats
bulk-load-profile only.Returns all benchmark statistics collected by this bulk-load request.
Sourcepub fn enable_direct_packet_writes(&mut self)
pub fn enable_direct_packet_writes(&mut self)
Enables the experimental direct packet write path for this bulk-load request.
The default path uses Tiberius’ framed packet sink. This opt-in path is intended for benchmark comparisons only: it preserves TDS packet framing while writing raw bulk packets directly to the underlying transport.
Direct mode changes the internal pending buffer from payload-only bytes to a header-prefixed packet buffer. The first 8 bytes are reserved for a TDS header and are filled immediately before writing each packet.
Normal query writes and requests that do not call this method continue using the framed sink path.
Sourcepub fn direct_packet_writes_enabled(&self) -> bool
pub fn direct_packet_writes_enabled(&self) -> bool
Returns true if this request uses the experimental direct packet writer.
Sourcepub async fn send_raw_row_payload(
&mut self,
payload: impl AsRef<[u8]>,
) -> Result<()>
pub async fn send_raw_row_payload( &mut self, payload: impl AsRef<[u8]>, ) -> Result<()>
Adds one already-encoded row value payload to the bulk insert.
The payload must contain only the encoded value bytes for one row. It
must not include the TDS ROW token byte. This method prefixes the
normal ROW token (0xD1) and then appends the payload to the same
packet buffer used by send.
Empty payloads are rejected. After the last row, finalize must be
called to flush the buffered data and complete the bulk load.
Sourcepub async fn send_raw_rows_payload(
&mut self,
payload: impl AsRef<[u8]>,
) -> Result<()>
pub async fn send_raw_rows_payload( &mut self, payload: impl AsRef<[u8]>, ) -> Result<()>
Adds already-encoded complete TDS rows to the bulk insert.
The payload must contain one or more complete TDS rows. Each row must
begin with the TDS ROW token byte (0xD1) followed by that row’s
encoded value payload. This is the batched raw path intended for callers
that encode many rows, such as one Arrow RecordBatch, before handing
bytes to Tiberius.
Empty payloads are rejected. This method performs only a cheap first-byte
check; callers are responsible for producing semantically valid row
bytes for this request’s columns. After the last batch, finalize
must be called to flush the buffered data and complete the bulk load.
Sourcepub async fn send_raw_rows_payload_checked(
&mut self,
payload: impl AsRef<[u8]>,
row_token_offsets: impl AsRef<[usize]>,
) -> Result<()>
pub async fn send_raw_rows_payload_checked( &mut self, payload: impl AsRef<[u8]>, row_token_offsets: impl AsRef<[usize]>, ) -> Result<()>
Adds already-encoded complete TDS rows with row-token offset checks.
This method has the same byte boundary as send_raw_rows_payload:
payload must contain one or more complete TDS rows and each row must
start with the TDS ROW token byte (0xD1). The row_token_offsets
slice identifies the byte offset of every row token in payload.
The offset checks are intended as a cheap validation layer for batched
encoders. They verify that offsets are non-empty, start at zero, are
strictly increasing, are in bounds, and point at ROW tokens. They do
not parse or validate the row value payloads.
Sourcepub async fn send_raw_rows_with<F>(&mut self, encode: F) -> Result<()>
pub async fn send_raw_rows_with<F>(&mut self, encode: F) -> Result<()>
Adds raw rows by encoding directly into this request’s packet buffer.
The closure receives the same internal buffer used by send and the
other raw bulk methods. It must append one or more complete TDS rows,
where each row starts with the TDS ROW token byte (0xD1), and then
return RawRowsAppend with row-token offsets relative to the appended
region.
If the closure returns an error, or if the appended region fails row-token validation, this method truncates the request buffer back to its original length before returning the error. On success, it uses the normal bulk-load packet splitting path.
Sourcepub async fn finalize(self) -> Result<ExecuteResult>
Available on crate feature bulk-load-profile only.
pub async fn finalize(self) -> Result<ExecuteResult>
bulk-load-profile only.Ends the bulk load, flushing all pending data to the wire.
This method must be called after sending all the data to flush all pending data and to get the server actually to store the rows to the table.
Sourcepub async fn finalize_with_packet_stats(
self,
) -> Result<(ExecuteResult, BulkLoadPacketStats)>
Available on crate feature bulk-load-profile only.
pub async fn finalize_with_packet_stats( self, ) -> Result<(ExecuteResult, BulkLoadPacketStats)>
bulk-load-profile only.Ends the bulk load and returns packet statistics collected by the request.
This method has the same write behavior as finalize, but also
returns the final packet counters that are otherwise unavailable because
finalization consumes the request.
Sourcepub async fn finalize_with_stats(self) -> Result<(ExecuteResult, BulkLoadStats)>
Available on crate feature bulk-load-profile only.
pub async fn finalize_with_stats(self) -> Result<(ExecuteResult, BulkLoadStats)>
bulk-load-profile only.Ends the bulk load and returns all benchmark statistics collected by the request.
This method has the same write behavior as finalize, but returns
packet counters and write timing counters after finalization consumes
the request.