pub struct AsyncArrowInserterOwned { /* private fields */ }Expand description
Owned-handle variant of AsyncArrowInserter that holds an
Arc<AsyncConnection> instead of a borrow.
Semantics are identical to AsyncArrowInserter — same
HyperBinary Arrow-stream COPY pipeline, same flush threshold,
same Drop-time best-effort cancel. The only difference is that
this variant is 'static and can therefore live in structs that
can’t carry lifetimes (N-API classes, tokio::spawn tasks that
outlive the constructor’s stack frame, etc).
Implementations§
Source§impl AsyncArrowInserterOwned
impl AsyncArrowInserterOwned
Sourcepub fn new(
connection: Arc<AsyncConnection>,
table_def: &TableDefinition,
) -> Result<Self>
pub fn new( connection: Arc<AsyncConnection>, table_def: &TableDefinition, ) -> Result<Self>
Creates a new owned-handle async Arrow inserter.
§Arguments
connection-Arc-shared async database connection. The Arc is cloned into the inserter and kept alive for its lifetime, so callers can drop their own handle immediately after construction.table_def- The table definition for the target table.
§Errors
- Returns
Error::Otherwith message"Table definition must have at least one column"iftable_defhas no columns. - Returns
Error::Otherifconnectionis using gRPC transport.
Sourcepub fn with_flush_threshold(self, threshold: usize) -> Self
pub fn with_flush_threshold(self, threshold: usize) -> Self
Sets a custom flush threshold in bytes. Default: 16 MB.
Sourcepub async fn insert_data(&mut self, arrow_ipc_data: &[u8]) -> Result<()>
pub async fn insert_data(&mut self, arrow_ipc_data: &[u8]) -> Result<()>
Inserts a complete Arrow IPC stream (schema + record batches).
Use this for single-chunk inserts or as the first call of a
multi-chunk insert; subsequent chunks use
insert_record_batches.
§Errors
- Returns
Error::Otherif a schema was already sent. - Returns
Error::Other/Error::Clientif the lazy COPY session cannot be opened. - Returns
Error::Client/Error::Ioif the server rejects the data or the socket write fails.
Sourcepub async fn insert_record_batches(
&mut self,
arrow_batch_data: &[u8],
) -> Result<()>
pub async fn insert_record_batches( &mut self, arrow_batch_data: &[u8], ) -> Result<()>
Inserts Arrow record-batch bytes without a schema header.
Must be called after insert_data or
insert_raw.
§Errors
- Returns
Error::Otherif no schema has been sent yet. - Returns
Error::Client/Error::Ioif the server rejects the data or the socket write fails.
Sourcepub async fn insert_raw(&mut self, data: &[u8]) -> Result<()>
pub async fn insert_raw(&mut self, data: &[u8]) -> Result<()>
Low-level: send raw bytes without schema tracking. The first
call transitions schema_sent to true. Use this when you are
managing Arrow IPC framing yourself.
§Errors
- Returns
Error::Other/Error::Clientif the lazy COPY session cannot be opened. - Returns
Error::Client/Error::Ioif the server rejects the data or the socket write fails.
Sourcepub async fn execute(self) -> Result<u64>
pub async fn execute(self) -> Result<u64>
Finalizes the COPY session and returns the affected row count.
§Errors
- Returns
Error::Otherwith message"No data was inserted before execute()"if no COPY session was ever opened. - Returns
Error::Client/Error::Ioif theCommandCompleteround-trip fails.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Returns the total bytes sent.
Sourcepub fn chunk_count(&self) -> usize
pub fn chunk_count(&self) -> usize
Returns the number of chunks sent.
Trait Implementations§
Source§impl Debug for AsyncArrowInserterOwned
impl Debug for AsyncArrowInserterOwned
Source§impl Drop for AsyncArrowInserterOwned
impl Drop for AsyncArrowInserterOwned
Auto Trait Implementations§
impl Freeze for AsyncArrowInserterOwned
impl !RefUnwindSafe for AsyncArrowInserterOwned
impl Send for AsyncArrowInserterOwned
impl Sync for AsyncArrowInserterOwned
impl Unpin for AsyncArrowInserterOwned
impl UnsafeUnpin for AsyncArrowInserterOwned
impl !UnwindSafe for AsyncArrowInserterOwned
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request