pub struct ArrowRowset { /* private fields */ }Expand description
Parsed Arrow result set for streaming row access.
Constructed either from fully materialized bytes
(from_bytes, from_buffer,
from_chunks, from_ipc_slice)
or from a lazy chunk source
(from_stream).
The lazy constructor pulls and decodes chunks on demand from
next_chunk, so for very large result sets (GB-class
gRPC query results) peak client memory is bounded by roughly one chunk
plus whatever batches the caller is holding, rather than growing to the
full result size.
Implementations§
Source§impl ArrowRowset
impl ArrowRowset
Sourcepub fn from_bytes(bytes: Bytes) -> Result<Self>
pub fn from_bytes(bytes: Bytes) -> Result<Self>
Parse Arrow IPC bytes from a shared Bytes handle (zero-copy).
Tolerant of two shapes:
- a single continuous Arrow IPC stream (what libpq COPY TO STDOUT
with
arrowstreamformat produces), or - one or more self-contained streams concatenated end-to-end (what
hyperd’s gRPC
execute_query_to_arrowproduces when the server split the result across multipleBinaryPartmessages —into_arrow_dataglued them together).
Arrow record batches reference the same allocation as the input
Bytes, so fixed-width columns do not incur any memcpy. Prefer this
over from_ipc_slice whenever you already
have a Bytes (which is the native return type of the gRPC path).
§Errors
Returns Error::Other wrapping an Arrow IPC decode error if
bytes is not a valid Arrow IPC stream (or concatenation thereof).
Sourcepub fn from_buffer(buf: Buffer) -> Result<Self>
pub fn from_buffer(buf: Buffer) -> Result<Self>
Parse Arrow IPC bytes from an arrow Buffer (zero-copy).
See from_bytes for how this tolerates both
continuous and concatenated-stream inputs.
§Errors
Returns Error::Other wrapping an Arrow IPC decode error if
buf is not a valid Arrow IPC stream.
Sourcepub fn from_chunks<I>(chunks: I) -> Result<Self>where
I: IntoIterator<Item = Bytes>,
pub fn from_chunks<I>(chunks: I) -> Result<Self>where
I: IntoIterator<Item = Bytes>,
Parse Arrow IPC bytes from multiple independent chunks (zero-copy).
Each chunk is treated as its own self-contained Arrow IPC stream
(schema + batches + optional EOS). This matches hyperd’s gRPC
output, where every BinaryPart message carries a fresh schema.
For a single continuous stream, use from_bytes.
§Errors
Returns Error::Other wrapping an Arrow IPC decode error if any
chunk cannot be parsed as a self-contained IPC stream.
Sourcepub fn from_stream(source: Box<dyn ChunkSource>) -> Result<Self>
pub fn from_stream(source: Box<dyn ChunkSource>) -> Result<Self>
Build a streaming rowset that pulls chunks from source on demand.
Unlike the from_* constructors, this does not pre-decode the
whole IPC stream up front. Each call to
next_chunk pulls just enough bytes from
source to produce one Arrow RecordBatch. Peak memory is bounded
by one source chunk (typically the tonic max_decoding_message_size
default of 64 MB) plus any batches the caller is still holding —
regardless of total result size.
The first source chunk is pulled eagerly so that schema
returns the real schema before the first next_chunk call. If the
stream is empty, an empty rowset with Schema::empty() is returned.
§Errors
- Returns the transport error from
source.next_chunk()when priming the decoder with the first chunk. - Returns
Error::Otherwrapping an Arrow IPC decode error if that first chunk is not a valid Arrow IPC stream prefix.
Sourcepub fn from_ipc_slice(data: &[u8]) -> Result<Self>
pub fn from_ipc_slice(data: &[u8]) -> Result<Self>
Parse Arrow IPC bytes from a borrowed slice.
This copies data into an arrow Buffer before decoding. Prefer
from_bytes when you already own a Bytes.
§Errors
Returns Error::Other wrapping an Arrow IPC decode error if
data is not a valid Arrow IPC stream.
Sourcepub fn column_count(&self) -> usize
pub fn column_count(&self) -> usize
Returns the number of columns.
Sourcepub fn column_names(&self) -> Vec<String>
pub fn column_names(&self) -> Vec<String>
Returns column names.
Sourcepub fn column_name(&self, index: usize) -> Option<&str>
pub fn column_name(&self, index: usize) -> Option<&str>
Returns the column name at the given index.
Sourcepub fn next_chunk(&mut self) -> Result<Option<ArrowChunk>>
pub fn next_chunk(&mut self) -> Result<Option<ArrowChunk>>
Gets the next chunk of rows.
For buffered rowsets this walks a preallocated Vec<RecordBatch>.
For streaming rowsets it pulls and decodes source chunks on demand
until at least one record batch is ready (or the source is
exhausted).
§Errors
For streaming rowsets:
- Returns the transport error from
source.next_chunk(). - Returns
Error::Otherwrapping an Arrow IPC decode error if a chunk contains malformed stream bytes.
Buffered rowsets never error — they walk a pre-decoded vector.
Sourcepub fn total_rows(&self) -> usize
pub fn total_rows(&self) -> usize
Returns the total number of rows across all batches.
For streaming rowsets this reflects only batches decoded so far —
until next_chunk has pulled everything from the
source, the total is not yet known.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no rows available right now.
For streaming rowsets this only reflects the currently-decoded
batches, not the full result — a streaming rowset that has not been
iterated will usually report is_empty() == true even if the server
will send more data on next_chunk.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArrowRowset
impl !RefUnwindSafe for ArrowRowset
impl Send for ArrowRowset
impl !Sync for ArrowRowset
impl Unpin for ArrowRowset
impl UnsafeUnpin for ArrowRowset
impl !UnwindSafe for ArrowRowset
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