Skip to main content

BulkLoadRequest

Struct BulkLoadRequest 

Source
pub struct BulkLoadRequest<'a, S>
where S: AsyncRead + AsyncWrite + Unpin + Send,
{ /* private fields */ }
Expand description

A handler for a bulk insert data flow.

Implementations§

Source§

impl<'a, S> BulkLoadRequest<'a, S>
where S: AsyncRead + AsyncWrite + Unpin + Send,

Source

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.

Source

pub fn packet_stats(&self) -> BulkLoadPacketStats

Available on crate feature bulk-load-profile only.

Returns packet-write statistics collected by this bulk-load request.

Source

pub fn write_timing_stats(&self) -> BulkLoadWriteTimingStats

Available on crate feature bulk-load-profile only.

Returns write timing statistics collected by this bulk-load request.

Source

pub fn stats(&self) -> BulkLoadStats

Available on crate feature bulk-load-profile only.

Returns all benchmark statistics collected by this bulk-load request.

Source

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.

Source

pub fn direct_packet_writes_enabled(&self) -> bool

Returns true if this request uses the experimental direct packet writer.

Source

pub async fn send(&mut self, row: TokenRow<'a>) -> Result<()>

Adds a new row to the bulk insert, flushing only when having a full packet of data.

§Warning

After the last row, finalize must be called to flush the buffered data and for the data to actually be available in the table.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn finalize(self) -> Result<ExecuteResult>

Available on crate feature 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.

Source

pub async fn finalize_with_packet_stats( self, ) -> Result<(ExecuteResult, BulkLoadPacketStats)>

Available on crate feature 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.

Source

pub async fn finalize_with_stats(self) -> Result<(ExecuteResult, BulkLoadStats)>

Available on crate feature 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.

Trait Implementations§

Source§

impl<'a, S> Debug for BulkLoadRequest<'a, S>
where S: AsyncRead + AsyncWrite + Unpin + Send + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for BulkLoadRequest<'a, S>

§

impl<'a, S> RefUnwindSafe for BulkLoadRequest<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for BulkLoadRequest<'a, S>

§

impl<'a, S> Sync for BulkLoadRequest<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for BulkLoadRequest<'a, S>

§

impl<'a, S> UnsafeUnpin for BulkLoadRequest<'a, S>

§

impl<'a, S> !UnwindSafe for BulkLoadRequest<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more