pub struct EventBatch { /* private fields */ }Expand description
Immutable columnar batch of events sharing one schema.
Implementations§
Source§impl EventBatch
impl EventBatch
Sourcepub fn new(
schema: Arc<Schema>,
p4s: Vec<Arc<[RealVec4]>>,
scalars: Vec<Arc<[f64]>>,
weights: Option<Arc<[f64]>>,
) -> LadduDataResult<Self>
pub fn new( schema: Arc<Schema>, p4s: Vec<Arc<[RealVec4]>>, scalars: Vec<Arc<[f64]>>, weights: Option<Arc<[f64]>>, ) -> LadduDataResult<Self>
Validates column counts and lengths and constructs a batch.
§Errors
Returns LadduDataError when column counts do not match schema or
column and weight lengths are inconsistent.
Sourcepub fn new_with_columns(
schema: Arc<Schema>,
p4s: Vec<Arc<[RealVec4]>>,
scalars: Vec<Arc<[f64]>>,
columns: Vec<Column>,
weights: Option<Arc<[f64]>>,
) -> LadduDataResult<Self>
pub fn new_with_columns( schema: Arc<Schema>, p4s: Vec<Arc<[RealVec4]>>, scalars: Vec<Arc<[f64]>>, columns: Vec<Column>, weights: Option<Arc<[f64]>>, ) -> LadduDataResult<Self>
Constructs a batch including exact non-expression columns.
§Errors
Returns an error for schema, dtype, or column-length mismatches.
Sourcepub fn new_with_columns_and_len(
schema: Arc<Schema>,
p4s: Vec<Arc<[RealVec4]>>,
scalars: Vec<Arc<[f64]>>,
columns: Vec<Column>,
weights: Option<Arc<[f64]>>,
len: usize,
) -> LadduDataResult<Self>
pub fn new_with_columns_and_len( schema: Arc<Schema>, p4s: Vec<Arc<[RealVec4]>>, scalars: Vec<Arc<[f64]>>, columns: Vec<Column>, weights: Option<Arc<[f64]>>, len: usize, ) -> LadduDataResult<Self>
Constructs a typed batch with an explicit row count.
§Errors
Returns an error if columns do not match the schema or row count.
Sourcepub fn new_with_len(
schema: Arc<Schema>,
p4s: Vec<Arc<[RealVec4]>>,
scalars: Vec<Arc<[f64]>>,
weights: Option<Arc<[f64]>>,
len: usize,
) -> LadduDataResult<Self>
pub fn new_with_len( schema: Arc<Schema>, p4s: Vec<Arc<[RealVec4]>>, scalars: Vec<Arc<[f64]>>, weights: Option<Arc<[f64]>>, len: usize, ) -> LadduDataResult<Self>
Constructs a batch with an explicit event count, including column-free events.
§Errors
Returns an error if the columns do not match the schema or event count.
Sourcepub fn from_events<I>(schema: Arc<Schema>, events: I) -> LadduDataResult<Self>where
I: IntoIterator<Item = OwnedEvent>,
pub fn from_events<I>(schema: Arc<Schema>, events: I) -> LadduDataResult<Self>where
I: IntoIterator<Item = OwnedEvent>,
Collects owned row events into a columnar batch.
§Errors
Returns LadduDataError when an event has the wrong number of values
or weighted and unweighted events are mixed.
Sourcepub fn row_ids(&self) -> Option<&[u64]>
pub fn row_ids(&self) -> Option<&[u64]>
Returns optional stable global source-row identities for distributed transforms.
Sourcepub fn with_row_ids(self, ids: Arc<[u64]>) -> LadduDataResult<Self>
pub fn with_row_ids(self, ids: Arc<[u64]>) -> LadduDataResult<Self>
Attaches stable source-row identities without changing the logical schema.
§Errors
Returns an error when the identity count differs from the event count.
Sourcepub fn bytes_per_event(&self) -> usize
pub fn bytes_per_event(&self) -> usize
Returns the logical payload bytes per event represented by this batch.
Sourcepub fn resident_bytes(&self) -> usize
pub fn resident_bytes(&self) -> usize
Returns the retained column and row-identity payload size in bytes.
Shared schema metadata, allocation headers, and other owners of shared columns are not included.
Sourcepub fn vec4_column(&self, index: usize) -> &[RealVec4]
pub fn vec4_column(&self, index: usize) -> &[RealVec4]
Returns a four-momentum column by index.
Sourcepub fn scalar_column(&self, index: usize) -> &[f64]
pub fn scalar_column(&self, index: usize) -> &[f64]
Returns a scalar column by index.
Sourcepub fn column(&self, index: usize) -> &Column
pub fn column(&self, index: usize) -> &Column
Returns an exact row-data column by index.
§Panics
Panics when the column index is outside the schema.
Sourcepub fn column_named(&self, name: &str) -> Option<&Column>
pub fn column_named(&self, name: &str) -> Option<&Column>
Returns an exact row-data column by name.
Sourcepub fn weights_column(&self) -> Option<&[f64]>
pub fn weights_column(&self) -> Option<&[f64]>
Returns the optional explicit weight column.
Sourcepub fn vec4_column_named(&self, name: &str) -> Option<&[RealVec4]>
pub fn vec4_column_named(&self, name: &str) -> Option<&[RealVec4]>
Returns a four-momentum column by logical name.
Sourcepub fn scalar_column_named(&self, name: &str) -> Option<&[f64]>
pub fn scalar_column_named(&self, name: &str) -> Option<&[f64]>
Returns a scalar column by logical name.
Sourcepub fn p4_column_bound(
&self,
binding: &P4Binding,
) -> LadduDataResult<&[RealVec4]>
pub fn p4_column_bound( &self, binding: &P4Binding, ) -> LadduDataResult<&[RealVec4]>
Returns a four-momentum column through a schema-resolved binding.
Schema compatibility is checked once, so callers can safely reuse the returned slice for every row in a packing loop.
§Errors
Returns LadduDataError::Schema when the binding belongs to another
schema.
Sourcepub fn scalar_column_bound(
&self,
binding: &ScalarBinding,
) -> LadduDataResult<&[f64]>
pub fn scalar_column_bound( &self, binding: &ScalarBinding, ) -> LadduDataResult<&[f64]>
Returns a scalar column through a schema-resolved binding.
Schema compatibility is checked once, so callers can safely reuse the returned slice for every row in a packing loop.
§Errors
Returns LadduDataError::Schema when the binding belongs to another
schema.
Sourcepub fn weights_at(&self, row: usize) -> f64
pub fn weights_at(&self, row: usize) -> f64
Returns the explicit row weight, or one when weights are absent.
Sourcepub fn event(&self, row: usize) -> BatchEvent<'_>
pub fn event(&self, row: usize) -> BatchEvent<'_>
Returns a borrowed view of one row.
Sourcepub fn iter(&self) -> impl Iterator<Item = BatchEvent<'_>>
pub fn iter(&self) -> impl Iterator<Item = BatchEvent<'_>>
Iterates over borrowed event views.
Sourcepub fn select(&self, rows: &[usize]) -> Self
pub fn select(&self, rows: &[usize]) -> Self
Copies selected rows into a new batch in the requested order.
§Panics
Panics when a selected row is outside the batch.
Sourcepub fn reweight<F>(&self, f: F) -> Self
pub fn reweight<F>(&self, f: F) -> Self
Returns a batch sharing value columns with newly computed weights.
§Panics
Panics if an internal batch invariant is violated while rebuilding the batch.
Sourcepub fn slice(&self, start: usize, end: usize) -> Self
pub fn slice(&self, start: usize, end: usize) -> Self
Copies the half-open row range start..end into a new batch.
§Panics
Panics when start > end or end exceeds the batch length.
Sourcepub fn concat(batches: &[Self]) -> LadduDataResult<Self>
pub fn concat(batches: &[Self]) -> LadduDataResult<Self>
Concatenates schema-compatible batches.
§Errors
Returns LadduDataError when batches is empty or contains
incompatible schemas.
Trait Implementations§
Source§impl Clone for EventBatch
impl Clone for EventBatch
Auto Trait Implementations§
impl Freeze for EventBatch
impl RefUnwindSafe for EventBatch
impl Send for EventBatch
impl Sync for EventBatch
impl Unpin for EventBatch
impl UnsafeUnpin for EventBatch
impl UnwindSafe for EventBatch
Blanket Implementations§
impl<T> Allocation for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.