pub struct NdRecordBatch { /* private fields */ }Expand description
A record batch whose columns are NdArrowArrays over a shared target grid.
Each column can use a subset of the target dimensions: a scalar attribute,
a 1-D coordinate, a full-rank data variable. Columns stay un-broadcast.
The schema is the logical schema: one field per column, typed by its values.
Global attributes describe the whole batch, like xarray Dataset.attrs.
Implementations§
Source§impl NdRecordBatch
impl NdRecordBatch
Sourcepub fn try_new(
schema: SchemaRef,
columns: Vec<NdArrowArray>,
target: Dimensions,
) -> Result<Self>
pub fn try_new( schema: SchemaRef, columns: Vec<NdArrowArray>, target: Dimensions, ) -> Result<Self>
Create a batch. The schema must match the column types, and every column
must broadcast onto target.
Sourcepub fn with_attributes(self, attributes: Attributes) -> Self
pub fn with_attributes(self, attributes: Attributes) -> Self
Replace the global attributes.
Sourcepub fn attributes(&self) -> &Attributes
pub fn attributes(&self) -> &Attributes
The global attributes of the batch.
Sourcepub fn attributes_mut(&mut self) -> &mut Attributes
pub fn attributes_mut(&mut self) -> &mut Attributes
The global attributes, for changes in place.
Sourcepub fn try_new_inferred(
schema: SchemaRef,
columns: Vec<NdArrowArray>,
) -> Result<Self>
pub fn try_new_inferred( schema: SchemaRef, columns: Vec<NdArrowArray>, ) -> Result<Self>
A batch with the target grid inferred by infer_target.
Sourcepub fn schema(&self) -> &SchemaRef
pub fn schema(&self) -> &SchemaRef
The logical schema: one field per column, typed by its values.
Sourcepub fn columns(&self) -> &[NdArrowArray]
pub fn columns(&self) -> &[NdArrowArray]
All columns, in schema order.
Sourcepub fn column(&self, index: usize) -> &NdArrowArray
pub fn column(&self, index: usize) -> &NdArrowArray
The column at index. Panics when index is out of bounds.
Sourcepub fn column_by_name(&self, name: &str) -> Option<&NdArrowArray>
pub fn column_by_name(&self, name: &str) -> Option<&NdArrowArray>
The column named name, if present.
Sourcepub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
The number of columns.
Sourcepub fn target(&self) -> &Dimensions
pub fn target(&self) -> &Dimensions
The shared target grid.
Sourcepub fn to_record_batch(&self) -> Result<RecordBatch>
pub fn to_record_batch(&self) -> Result<RecordBatch>
Encode as a single-row RecordBatch of nd columns.
Sourcepub fn try_from_record_batch(batch: &RecordBatch) -> Result<Vec<Self>>
pub fn try_from_record_batch(batch: &RecordBatch) -> Result<Vec<Self>>
Decode every row of an nd-encoded RecordBatch: one nd batch per row.
Sourcepub fn try_from_record_batch_row(
batch: &RecordBatch,
row: usize,
) -> Result<Self>
pub fn try_from_record_batch_row( batch: &RecordBatch, row: usize, ) -> Result<Self>
Decode row row of an nd-encoded RecordBatch.
Source§impl NdRecordBatch
impl NdRecordBatch
Sourcepub fn materialize(&self) -> Result<RecordBatch>
pub fn materialize(&self) -> Result<RecordBatch>
Broadcast every column onto the target grid and return a flat
RecordBatch with one row per grid cell, in C order.
Sourcepub fn coordinate(&self, dim: &str) -> Option<&NdArrowArray>
pub fn coordinate(&self, dim: &str) -> Option<&NdArrowArray>
The coordinate of dim: a column named dim with dimensions (dim).
Sourcepub fn isel(&self, selections: &[(&str, Selector)]) -> Result<Self>
pub fn isel(&self, selections: &[(&str, Selector)]) -> Result<Self>
Select by position on target dimensions, like xarray Dataset.isel.
The batch kernels keep the global attributes.
Each column gets the selections of its own dimensions. A column with size 1 on a selected dimension keeps broadcasting, and an index selection removes that axis.
Sourcepub fn sel_range(
&self,
dim: &str,
start: Option<&ArrayRef>,
end: Option<&ArrayRef>,
) -> Result<Self>
pub fn sel_range( &self, dim: &str, start: Option<&ArrayRef>, end: Option<&ArrayRef>, ) -> Result<Self>
Select the positions whose coordinate lies in [start, end], like
xarray sel with a label slice. An open end is None.
The coordinate must be sorted, ascending or descending, without nulls.
Sourcepub fn sel_nearest(&self, dim: &str, value: &ArrayRef) -> Result<Self>
pub fn sel_nearest(&self, dim: &str, value: &ArrayRef) -> Result<Self>
Select the position whose coordinate is nearest to value, like xarray
sel(method="nearest"). The dimension is removed. Ties pick the first.
Trait Implementations§
Source§impl Clone for NdRecordBatch
impl Clone for NdRecordBatch
Auto Trait Implementations§
impl !RefUnwindSafe for NdRecordBatch
impl !UnwindSafe for NdRecordBatch
impl Freeze for NdRecordBatch
impl Send for NdRecordBatch
impl Sync for NdRecordBatch
impl Unpin for NdRecordBatch
impl UnsafeUnpin for NdRecordBatch
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more