pub struct ArrowRleBatch { /* private fields */ }Expand description
Many Arrow-backed sequences, each identified by a row of a key table.
The keys are a RecordBatch with any number of columns of any types
(for example a chromosome and a strand column), one row per sequence.
Sequences are stored back to back: sequence i is runs
offsets[i]..offsets[i + 1] of ends and values, with ends restarting
at 0. Batch operations run in parallel across sequences.
Implementations§
Source§impl ArrowRleBatch
impl ArrowRleBatch
Sourcepub fn try_new(
keys: RecordBatch,
offsets: Vec<usize>,
ends: Vec<i64>,
values: ArrayRef,
) -> Result<Self>
pub fn try_new( keys: RecordBatch, offsets: Vec<usize>, ends: Vec<i64>, values: ArrayRef, ) -> Result<Self>
Builds a batch from its flat parts, validating them. Keys must be unique.
Sourcepub fn from_rles(
keys: RecordBatch,
rles: Vec<ArrowRle>,
data_type: &DataType,
) -> Result<Self>
pub fn from_rles( keys: RecordBatch, rles: Vec<ArrowRle>, data_type: &DataType, ) -> Result<Self>
Builds a batch from one key row and one sequence per entry. All
sequences must have the same value type, data_type.
pub fn is_empty(&self) -> bool
Sourcepub fn keys(&self) -> &RecordBatch
pub fn keys(&self) -> &RecordBatch
The key table, one row per sequence.
pub fn offsets(&self) -> &[usize]
Sourcepub fn get_index(&self, position: usize) -> Option<ArrowRle>
pub fn get_index(&self, position: usize) -> Option<ArrowRle>
The sequence at position. The values are a zero-copy slice.
Sourcepub fn positions(&self, keys: &RecordBatch) -> Result<Vec<Option<usize>>>
pub fn positions(&self, keys: &RecordBatch) -> Result<Vec<Option<usize>>>
The position of each row of keys in this batch, or None if absent.
keys must have the same column types as this batch’s keys.
Sourcepub fn zip_with<F>(
&self,
other: &ArrowRleBatch,
how: How,
fill_a: Option<&dyn Array>,
fill_b: Option<&dyn Array>,
f: F,
) -> Result<ArrowRleBatch>
pub fn zip_with<F>( &self, other: &ArrowRleBatch, how: How, fill_a: Option<&dyn Array>, fill_b: Option<&dyn Array>, f: F, ) -> Result<ArrowRleBatch>
Combines two batches key by key, in parallel, merging each result.
Both key tables must have the same column names and types. how picks
the keys, which appear in the left batch’s order followed by keys only
in the right batch. A key missing on one side is an empty sequence
there, padded with that side’s fill value. See
ArrowRle::zip_with for f.
Sourcepub fn to_record_batch(&self) -> Result<RecordBatch>
pub fn to_record_batch(&self) -> Result<RecordBatch>
The batch as one long table: the key columns, then start, end and
value, with one row per run. This is the natural shape for polars or
pandas.
Sourcepub fn zip_with_default(
&self,
other: &ArrowRleBatch,
f: Kernel,
) -> Result<ArrowRleBatch>
pub fn zip_with_default( &self, other: &ArrowRleBatch, f: Kernel, ) -> Result<ArrowRleBatch>
Combines with other by an outer join, using default_fill on each
side, and merges.
Source§impl ArrowRleBatch
impl ArrowRleBatch
Sourcepub fn add(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn add(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise addition (integer overflow is an error). Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn sub(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn sub(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise subtraction (integer overflow is an error). Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn mul(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn mul(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise multiplication (integer overflow is an error). Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn div(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn div(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise division (integer division by zero is an error). Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn elem_eq(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn elem_eq(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise ==. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn elem_ne(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn elem_ne(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise !=. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn elem_lt(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn elem_lt(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise <. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn elem_le(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn elem_le(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise <=. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn elem_gt(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn elem_gt(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise >. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn elem_ge(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn elem_ge(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise >=. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn and(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn and(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise logical and, with SQL semantics for nulls. Keys are outer-joined and shorter sides padded with default_fill.
Sourcepub fn or(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
pub fn or(&self, other: &ArrowRleBatch) -> Result<ArrowRleBatch>
Element-wise logical or, with SQL semantics for nulls. Keys are outer-joined and shorter sides padded with default_fill.
Source§impl ArrowRleBatch
impl ArrowRleBatch
Sourcepub fn slice_agg(
&self,
keys: &RecordBatch,
starts: &[i64],
ends: &[i64],
agg: SliceAgg,
) -> Result<ArrayRef>
pub fn slice_agg( &self, keys: &RecordBatch, starts: &[i64], ends: &[i64], agg: SliceAgg, ) -> Result<ArrayRef>
Like ArrowRle::slice_agg, where slice k is in the sequence of row
k of keys. A key not in the batch gives an empty slice. keys must
have the same column names and types as the batch’s keys.
Source§impl ArrowRleBatch
impl ArrowRleBatch
Sourcepub fn collapse(&self, keep: &[&str], kernel: Kernel) -> Result<ArrowRleBatch>
pub fn collapse(&self, keep: &[&str], kernel: Kernel) -> Result<ArrowRleBatch>
Combines the sequences whose keys agree on the keep columns, folding
each group with kernel in key order, in parallel across groups.
For example, keeping only Chromosome with kernels::add adds the
strands of each chromosome together. Sequences of different lengths
are padded with default_fill.
Source§impl ArrowRleBatch
impl ArrowRleBatch
Sourcepub fn shift(&self, distance: i64, fill: &dyn Array) -> Result<ArrowRleBatch>
pub fn shift(&self, distance: i64, fill: &dyn Array) -> Result<ArrowRleBatch>
Shifts every sequence, in parallel; see ArrowRle::shift.
Sourcepub fn reversed(&self) -> Result<ArrowRleBatch>
pub fn reversed(&self) -> Result<ArrowRleBatch>
Reverses every sequence, in parallel.
Sourcepub fn map_rles<F>(&self, f: F) -> Result<ArrowRleBatch>
pub fn map_rles<F>(&self, f: F) -> Result<ArrowRleBatch>
Transforms every sequence in parallel, keeping the keys. All results must have the same value type.
Sourcepub fn concat(batches: &[ArrowRleBatch]) -> Result<ArrowRleBatch>
pub fn concat(batches: &[ArrowRleBatch]) -> Result<ArrowRleBatch>
Joins batches end to end key by key, in parallel: each key’s sequences are concatenated in batch order, and a batch without the key adds nothing. Keys appear in order of first appearance. All batches must have the same key columns and value type.
Trait Implementations§
Source§impl Clone for ArrowRleBatch
impl Clone for ArrowRleBatch
Source§impl Debug for ArrowRleBatch
impl Debug for ArrowRleBatch
Auto Trait Implementations§
impl !RefUnwindSafe for ArrowRleBatch
impl !UnwindSafe for ArrowRleBatch
impl Freeze for ArrowRleBatch
impl Send for ArrowRleBatch
impl Sync for ArrowRleBatch
impl Unpin for ArrowRleBatch
impl UnsafeUnpin for ArrowRleBatch
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