Skip to main content

NdRecordBatch

Struct NdRecordBatch 

Source
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

Source

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.

Source

pub fn with_attributes(self, attributes: Attributes) -> Self

Replace the global attributes.

Source

pub fn attributes(&self) -> &Attributes

The global attributes of the batch.

Source

pub fn attributes_mut(&mut self) -> &mut Attributes

The global attributes, for changes in place.

Source

pub fn try_new_inferred( schema: SchemaRef, columns: Vec<NdArrowArray>, ) -> Result<Self>

A batch with the target grid inferred by infer_target.

Source

pub fn schema(&self) -> &SchemaRef

The logical schema: one field per column, typed by its values.

Source

pub fn columns(&self) -> &[NdArrowArray]

All columns, in schema order.

Source

pub fn column(&self, index: usize) -> &NdArrowArray

The column at index. Panics when index is out of bounds.

Source

pub fn column_by_name(&self, name: &str) -> Option<&NdArrowArray>

The column named name, if present.

Source

pub fn num_columns(&self) -> usize

The number of columns.

Source

pub fn target(&self) -> &Dimensions

The shared target grid.

Source

pub fn num_rows(&self) -> usize

Rows after a broadcast onto the full target grid.

Source

pub fn to_record_batch(&self) -> Result<RecordBatch>

Encode as a single-row RecordBatch of nd columns.

Source

pub fn try_from_record_batch(batch: &RecordBatch) -> Result<Vec<Self>>

Decode every row of an nd-encoded RecordBatch: one nd batch per row.

Source

pub fn try_from_record_batch_row( batch: &RecordBatch, row: usize, ) -> Result<Self>

Decode row row of an nd-encoded RecordBatch.

Source§

impl NdRecordBatch

Source

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.

Source

pub fn coordinate(&self, dim: &str) -> Option<&NdArrowArray>

The coordinate of dim: a column named dim with dimensions (dim).

Source

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.

Source

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.

Source

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.

Source

pub fn interp(&self, dim: &str, new_coords: &NdArrowArray) -> Result<Self>

Interpolate every column along dim onto new_coords, see interp.

Columns that span dim must be numeric and become floating point. The coordinate becomes new_coords. Other columns stay unchanged.

Source

pub fn resample( &self, dim: &str, freq: Frequency, op: Reduction, ) -> Result<Self>

Resample every column along dim with the time coordinate of dim, see resample.

Columns that span dim are reduced with op. The coordinate becomes the bin starts. Other columns stay unchanged.

Trait Implementations§

Source§

impl Clone for NdRecordBatch

Source§

fn clone(&self) -> Self

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 Debug for NdRecordBatch

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.