pub struct Frame(/* private fields */);Expand description
Rows and columns, together with what each column is called and holds.
A type of ours rather than a RecordBatch in an Opaque for two reasons
that are not style: a codec is an impl of somebody else’s trait and the
orphan rule wants one of the two types to be ours, and this is the word the
design is written in — the difference between training and deploying is how
many rows the frame brings.
It is not a tensor and does not want to be. Numbers and fixed-size lists of them are contiguous Arrow buffers, so converting is a reshape and not a copy; text is not a tensor until something tokenizes it. The conversion is a node, and the same node whether the frame came from a file or a topic.
Implementations§
Source§impl Frame
impl Frame
Sourcepub const KIND: &'static str = "arrow.RecordBatch"
pub const KIND: &'static str = "arrow.RecordBatch"
What gets written beside the bytes. Named after the format and not
the language: what is on disk is an Arrow IPC stream, and whoever reads
it back may be a polars on the other side of the wall.
Sourcepub fn rows(&self) -> usize
pub fn rows(&self) -> usize
How many rows it brings. The only number a caller usually wants: it is what says whether a span was short because the dataset ended.
Sourcepub fn schema(&self) -> &SchemaRef
pub fn schema(&self) -> &SchemaRef
What the columns are called and what they hold — without reading a value, which is the half of a virtual table worth having.
Sourcepub fn value(self) -> Value
pub fn value(self) -> Value
As a value, which is how it crosses an edge. Opaque and not a variant
of its own: the core has no dependencies and is not going to learn what a
column is.
Sourcepub fn written(&self) -> Result<Vec<u8>, FrameError>
pub fn written(&self) -> Result<Vec<u8>, FrameError>
What it weighs in bytes: Arrow IPC, buffers and all. No encoding pass and no per-value work, which is the reason Arrow is the type that crosses an edge rather than something converted to at the edges.
Sourcepub fn read(bytes: &[u8]) -> Result<Self, FrameError>
pub fn read(bytes: &[u8]) -> Result<Self, FrameError>
And back.
One frame, however many batches the stream holds: what was written down was a frame, and a frame is what comes back.