pub struct Dataset { /* private fields */ }Expand description
Lazy event dataset combining a source, read plan, and row transformations.
Implementations§
Source§impl Dataset
impl Dataset
Sourcepub fn new<S>(source: S) -> Selfwhere
S: EventSource + 'static,
pub fn new<S>(source: S) -> Selfwhere
S: EventSource + 'static,
Creates a dataset from an event source.
Sourcepub fn from_arc(source: Arc<dyn EventSource>) -> Self
pub fn from_arc(source: Arc<dyn EventSource>) -> Self
Creates a dataset from a shared dynamically dispatched source.
Sourcepub fn from_batch(batch: EventBatch) -> Self
pub fn from_batch(batch: EventBatch) -> Self
Creates an in-memory dataset from one batch.
Sourcepub fn from_batches(batches: Vec<EventBatch>) -> LadduDataResult<Self>
pub fn from_batches(batches: Vec<EventBatch>) -> LadduDataResult<Self>
Creates an in-memory dataset from schema-compatible batches.
§Errors
Returns LadduDataError when batch schemas are incompatible.
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 events into an in-memory dataset.
§Errors
Returns LadduDataError when an event does not match schema.
Sourcepub fn schema(&self) -> LadduDataResult<Arc<Schema>>
pub fn schema(&self) -> LadduDataResult<Arc<Schema>>
Returns the source schema.
§Errors
Returns LadduDataError when the underlying source cannot determine
or load its schema.
Sourcepub fn capabilities(&self) -> SourceCapabilities
pub fn capabilities(&self) -> SourceCapabilities
Returns source planning capabilities.
Sourcepub fn num_events(&self) -> LadduDataResult<Option<u64>>
pub fn num_events(&self) -> LadduDataResult<Option<u64>>
Returns the source event count when cheaply available.
§Errors
Returns an error when source metadata cannot be read.
Sourcepub fn stats(&self) -> LadduDataResult<DatasetStats>
pub fn stats(&self) -> LadduDataResult<DatasetStats>
Returns cached event-count and weight-sum statistics, computing them once if needed.
Clones of a dataset view share this cache. Failed traversals are not cached and may be retried.
§Errors
Returns LadduDataError when reading or transforming the dataset fails.
Sourcepub fn cache_storage(&self) -> CacheStorage
pub fn cache_storage(&self) -> CacheStorage
Returns the compiled-cache memory policy.
Sourcepub fn memory_policy(&self) -> MemoryPolicy
pub fn memory_policy(&self) -> MemoryPolicy
Returns the memory-first cache selection policy.
Sourcepub fn memory_budget(&self) -> MemoryBudget
pub fn memory_budget(&self) -> MemoryBudget
Returns the dataset’s host-memory budget.
Sourcepub fn last_memory_decision(&self) -> Option<MemoryDecision>
pub fn last_memory_decision(&self) -> Option<MemoryDecision>
Returns the most recent memory-derived read decision.
Sourcepub fn source_traversals(&self) -> u64
pub fn source_traversals(&self) -> u64
Returns the number of transformed source iterators opened by this dataset view.
Sourcepub fn with_memory_budget(self, budget: MemoryBudget) -> Self
pub fn with_memory_budget(self, budget: MemoryBudget) -> Self
Returns this dataset with a host-memory budget.
Sourcepub fn resident(self) -> Self
pub fn resident(self) -> Self
Retain compiled event-dependent values for every local event.
This strict policy is intended for repeatedly evaluating a likelihood
and returns an error if the resident cache cannot fit. Dataset::fastest
is the default.
Sourcepub fn streaming(self) -> Self
pub fn streaming(self) -> Self
Re-read the source and rebuild one batch cache during each parameter evaluation.
Only fixed dataset statistics are retained. This minimizes memory use but requires a
repeatable source and is expected to be slower than Dataset::resident.
Sourcepub fn chunked(self, chunk_size: usize) -> LadduDataResult<Self>
pub fn chunked(self, chunk_size: usize) -> LadduDataResult<Self>
Returns this dataset with a low-level nonzero maximum event count.
Prefer Dataset::with_memory_budget for portable application code.
This explicit read-plan override remains available for source debugging
and reproducibility and is always capped by execution memory planning.
§Errors
Returns LadduDataError::InvalidArgument when chunk_size is zero.
Sourcepub fn subsample(self, fraction: f64, seed: u64) -> LadduDataResult<Self>
pub fn subsample(self, fraction: f64, seed: u64) -> LadduDataResult<Self>
Lazily retains a deterministic fraction of events.
§Errors
Returns LadduDataError::InvalidArgument when fraction is outside
[0, 1] or is NaN.
Sourcepub fn bootstrap(self, seed: u64) -> Self
pub fn bootstrap(self, seed: u64) -> Self
Applies deterministic Poisson bootstrap multiplicities to event weights.
Sourcepub fn for_each_event<F>(&self, f: F) -> LadduDataResult<()>
pub fn for_each_event<F>(&self, f: F) -> LadduDataResult<()>
Visits each transformed event.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn try_for_each_event<F>(&self, f: F) -> LadduDataResult<()>
pub fn try_for_each_event<F>(&self, f: F) -> LadduDataResult<()>
Visits each transformed event and stops at the first error.
§Errors
Returns the first LadduDataError produced by the source,
transformations, or callback.
Sourcepub fn try_map_events<T, F>(&self, f: F) -> LadduDataResult<Vec<T>>
pub fn try_map_events<T, F>(&self, f: F) -> LadduDataResult<Vec<T>>
Fallibly maps transformed events into a vector.
§Errors
Returns the first LadduDataError produced while reading,
transforming, or mapping an event.
Sourcepub fn map_events<T, F>(&self, f: F) -> LadduDataResult<Vec<T>>
pub fn map_events<T, F>(&self, f: F) -> LadduDataResult<Vec<T>>
Maps transformed events into a vector.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn try_fold_events<T, F>(&self, init: T, f: F) -> LadduDataResult<T>
pub fn try_fold_events<T, F>(&self, init: T, f: F) -> LadduDataResult<T>
Fallibly folds transformed events into an owned accumulator.
§Errors
Returns the first LadduDataError produced while reading,
transforming, or folding an event.
Sourcepub fn fold_events<T, F>(&self, init: T, f: F) -> LadduDataResult<T>
pub fn fold_events<T, F>(&self, init: T, f: F) -> LadduDataResult<T>
Folds transformed events into an owned accumulator.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn try_accumulate_events<T, F>(&self, acc: T, f: F) -> LadduDataResult<T>
pub fn try_accumulate_events<T, F>(&self, acc: T, f: F) -> LadduDataResult<T>
Fallibly updates a mutable accumulator for every transformed event.
§Errors
Returns the first LadduDataError produced while reading,
transforming, or accumulating an event.
Sourcepub fn accumulate_events<T, F>(&self, acc: T, f: F) -> LadduDataResult<T>
pub fn accumulate_events<T, F>(&self, acc: T, f: F) -> LadduDataResult<T>
Updates a mutable accumulator for every transformed event.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn sum_weights(&self) -> LadduDataResult<f64>
pub fn sum_weights(&self) -> LadduDataResult<f64>
Sums effective event weights.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn weighted_sum<F>(&self, f: F) -> LadduDataResult<f64>
pub fn weighted_sum<F>(&self, f: F) -> LadduDataResult<f64>
Sums weight * f(event) over transformed events.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn weighted_complex_sum<F>(&self, f: F) -> LadduDataResult<Complex64>
pub fn weighted_complex_sum<F>(&self, f: F) -> LadduDataResult<Complex64>
Sums complex weight * f(event) contributions.
§Errors
Returns LadduDataError when reading or transforming the source
fails.
Sourcepub fn batches(
&self,
) -> LadduDataResult<Box<dyn Iterator<Item = LadduDataResult<EventBatch>> + Send>>
pub fn batches( &self, ) -> LadduDataResult<Box<dyn Iterator<Item = LadduDataResult<EventBatch>> + Send>>
Opens an iterator of fully transformed event batches.
§Errors
Returns LadduDataError when the underlying source cannot initialize
a batch stream for the current plan.
Sourcepub fn try_for_each_batch<F>(&self, f: F) -> LadduDataResult<()>
pub fn try_for_each_batch<F>(&self, f: F) -> LadduDataResult<()>
Visits each transformed batch and stops at the first error.
§Errors
Returns the first LadduDataError produced by the source,
transformations, or callback.
Sourcepub fn map_batches<T, F>(&self, f: F) -> LadduDataResult<Vec<T>>where
F: FnMut(EventBatch) -> T,
pub fn map_batches<T, F>(&self, f: F) -> LadduDataResult<Vec<T>>where
F: FnMut(EventBatch) -> T,
Maps transformed batches into a vector.
§Errors
Returns LadduDataError when reading or transforming a batch fails.
Sourcepub fn write_to<S: EventSink>(&self, sink: &mut S) -> LadduDataResult<()>
pub fn write_to<S: EventSink>(&self, sink: &mut S) -> LadduDataResult<()>
Streams the transformed dataset into an event sink.
§Errors
Returns LadduDataError when reading, transforming, or writing a
batch fails, or the sink cannot begin or finish the stream.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Dataset
impl !UnwindSafe for Dataset
impl Freeze for Dataset
impl Send for Dataset
impl Sync for Dataset
impl Unpin for Dataset
impl UnsafeUnpin for Dataset
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 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.