pub struct MemorySource { /* private fields */ }Expand description
Replayable in-memory event source backed by one or more batches.
Implementations§
Source§impl MemorySource
impl MemorySource
Sourcepub fn empty(schema: Arc<Schema>) -> MemorySource
pub fn empty(schema: Arc<Schema>) -> MemorySource
Creates an empty replayable source with the supplied schema.
Empty derived datasets retain schema and source capabilities while yielding no batches. This is useful for partitioning operations where a valid empty result is distinct from an invalid source definition.
Sourcepub fn new(batch: EventBatch) -> MemorySource
pub fn new(batch: EventBatch) -> MemorySource
Creates a source containing one batch.
Sourcepub fn from_batches(
batches: Vec<EventBatch>,
) -> Result<MemorySource, LadduDataError>
pub fn from_batches( batches: Vec<EventBatch>, ) -> Result<MemorySource, LadduDataError>
Validates and creates a source from nonempty schema-compatible batches.
§Errors
Returns LadduDataError when batches is empty or contains
incompatible schemas.
Sourcepub fn from_events<I>(
schema: Arc<Schema>,
events: I,
) -> Result<MemorySource, LadduDataError>where
I: IntoIterator<Item = OwnedEvent>,
pub fn from_events<I>(
schema: Arc<Schema>,
events: I,
) -> Result<MemorySource, LadduDataError>where
I: IntoIterator<Item = OwnedEvent>,
Collects owned events into an in-memory source.
§Errors
Returns LadduDataError when an event does not match schema or
weighted and unweighted events are mixed.
Sourcepub fn schema_arc(&self) -> &Arc<Schema> ⓘ
pub fn schema_arc(&self) -> &Arc<Schema> ⓘ
Returns the shared schema.
Sourcepub fn batches_slice(&self) -> &[EventBatch]
pub fn batches_slice(&self) -> &[EventBatch]
Returns the backing batches.
Sourcepub fn into_batches(self) -> Arc<[EventBatch]> ⓘ
pub fn into_batches(self) -> Arc<[EventBatch]> ⓘ
Consumes the source and returns its shared batches.
Sourcepub fn into_batch(self) -> Result<EventBatch, LadduDataError>
pub fn into_batch(self) -> Result<EventBatch, LadduDataError>
Consumes and concatenates all batches.
§Errors
Returns LadduDataError when no batches are present or their schemas
are incompatible.
Trait Implementations§
Source§impl Clone for MemorySource
impl Clone for MemorySource
Source§fn clone(&self) -> MemorySource
fn clone(&self) -> MemorySource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemorySource
impl Debug for MemorySource
Source§impl EventSource for MemorySource
impl EventSource for MemorySource
Source§fn capabilities(&self) -> SourceCapabilities
fn capabilities(&self) -> SourceCapabilities
Source§fn num_events(&self) -> Result<Option<u64>, LadduDataError>
fn num_events(&self) -> Result<Option<u64>, LadduDataError>
Source§fn weighted_total(&self) -> Result<Option<f64>, LadduDataError>
fn weighted_total(&self) -> Result<Option<f64>, LadduDataError>
Source§fn batches(
&self,
plan: ReadPlan,
) -> Result<Box<dyn Iterator<Item = Result<EventBatch, LadduDataError>> + Send>, LadduDataError>
fn batches( &self, plan: ReadPlan, ) -> Result<Box<dyn Iterator<Item = Result<EventBatch, LadduDataError>> + Send>, LadduDataError>
plan. Read moreSource§impl FragmentedSource for MemorySource
impl FragmentedSource for MemorySource
Source§type Key = MemoryFragmentKey
type Key = MemoryFragmentKey
Source§fn fragments(
&self,
) -> Result<Vec<DataFragment<<MemorySource as FragmentedSource>::Key>>, LadduDataError>
fn fragments( &self, ) -> Result<Vec<DataFragment<<MemorySource as FragmentedSource>::Key>>, LadduDataError>
Source§fn read_fragment_range(
&self,
key: &<MemorySource as FragmentedSource>::Key,
local_start: usize,
local_len: usize,
chunk_size: Option<usize>,
) -> Result<Box<dyn Iterator<Item = Result<EventBatch, LadduDataError>> + Send>, LadduDataError>
fn read_fragment_range( &self, key: &<MemorySource as FragmentedSource>::Key, local_start: usize, local_len: usize, chunk_size: Option<usize>, ) -> Result<Box<dyn Iterator<Item = Result<EventBatch, LadduDataError>> + Send>, LadduDataError>
Auto Trait Implementations§
impl Freeze for MemorySource
impl RefUnwindSafe for MemorySource
impl Send for MemorySource
impl Sync for MemorySource
impl Unpin for MemorySource
impl UnsafeUnpin for MemorySource
impl UnwindSafe for MemorySource
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.