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: u64How many rows the batch has.
flags: u64Flags, 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>
impl<'a> Batch<'a>
Sourcepub const fn empty() -> Self
pub const fn empty() -> Self
An empty batch, which is how a decoder says a scan produced no more rows.
Sourcepub fn decode(version: u16, p: &mut Reader<'a>) -> Result<Self>
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.