Skip to main content

Batch

Struct Batch 

Source
pub struct Batch<'a> {
    pub rows: u64,
    pub flags: u64,
    pub nodes: Nodes<'a>,
    pub buffers: Buffers<'a>,
}
Expand description

The decoder handing back one batch of decoded rows.

A batch says how many rows it has and then describes the Arrow arrays behind them as a flat list of nodes and a flat list of buffers, both in the pre-order the schema puts its fields in. That is the same shape Arrow IPC uses, and it is the right one here for the same reason: the host already has the schema, so the schema decides how many nodes and buffers there should be and the batch only has to supply them.

Neither list carries a count. The record length bounds both of them, so a batch cannot claim a million columns without being large enough to describe a million columns. That is the same rule the container format follows, and it is the difference between allocation safety being structural and allocation safety being something a reviewer has to remember.

The buffers are not in this record. They are in the decoder’s memory, and the offsets say where. Whether those offsets are inside the decoder’s memory, and whether the bytes at them are a valid Arrow array, are two separate questions and neither of them is answered here.

Fields§

§rows: u64

How many rows the batch has.

§flags: u64

Flags, all currently reserved and required to be zero.

§nodes: Nodes<'a>

One node per array, in schema pre-order.

§buffers: Buffers<'a>

One reference per Arrow buffer, in schema pre-order.

Implementations§

Source§

impl<'a> Batch<'a>

Source

pub const VERSION: u16 = 1

The layout version of this record.

Source

pub const fn empty() -> Self

An empty batch, which is how a decoder says a scan produced no more rows.

Source

pub fn encode(&self, w: &mut Writer<'_>) -> Result<()>

Writes the record.

§Errors

Returns Error::BufferFull if the buffer runs out.

Source

pub fn decode(version: u16, p: &mut Reader<'a>) -> Result<Self>

Reads the record from its payload.

§Errors

Returns Error::UnsupportedVersion if the layout version is not one this build knows, Error::Truncated if the payload ends early, or Error::Malformed if either list is not a whole number of entries.

Trait Implementations§

Source§

impl<'a> Clone for Batch<'a>

Source§

fn clone(&self) -> Batch<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for Batch<'a>

Source§

impl<'a> Debug for Batch<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Batch<'a>

Source§

impl<'a> PartialEq for Batch<'a>

Source§

fn eq(&self, other: &Batch<'a>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Batch<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Batch<'a>

§

impl<'a> RefUnwindSafe for Batch<'a>

§

impl<'a> Send for Batch<'a>

§

impl<'a> Sync for Batch<'a>

§

impl<'a> Unpin for Batch<'a>

§

impl<'a> UnsafeUnpin for Batch<'a>

§

impl<'a> UnwindSafe for Batch<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.