Skip to main content

ArrowRowset

Struct ArrowRowset 

Source
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

Source

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 arrowstream format produces), or
  • one or more self-contained streams concatenated end-to-end (what hyperd’s gRPC execute_query_to_arrow produces when the server split the result across multiple BinaryPart messages — into_arrow_data glued 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).

Source

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.

Source

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.

Source

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::Other wrapping an Arrow IPC decode error if that first chunk is not a valid Arrow IPC stream prefix.
Source

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.

Source

pub fn schema(&self) -> &Arc<Schema>

Returns the schema of the result set.

Source

pub fn column_count(&self) -> usize

Returns the number of columns.

Source

pub fn column_names(&self) -> Vec<String>

Returns column names.

Source

pub fn column_name(&self, index: usize) -> Option<&str>

Returns the column name at the given index.

Source

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::Other wrapping an Arrow IPC decode error if a chunk contains malformed stream bytes.

Buffered rowsets never error — they walk a pre-decoded vector.

Source

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.

Source

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§

Source§

impl Debug for ArrowRowset

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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