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 new(batch: EventBatch) -> Self
pub fn new(batch: EventBatch) -> Self
Creates a source containing one batch.
Sourcepub fn from_batches(batches: Vec<EventBatch>) -> LadduDataResult<Self>
pub fn from_batches(batches: Vec<EventBatch>) -> LadduDataResult<Self>
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) -> 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 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) -> LadduDataResult<EventBatch>
pub fn into_batch(self) -> LadduDataResult<EventBatch>
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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Returns optional source capabilities.
Source§fn num_events(&self) -> LadduDataResult<Option<u64>>
fn num_events(&self) -> LadduDataResult<Option<u64>>
Returns the exact event count when cheaply available. Read more
Source§fn weighted_total(&self) -> LadduDataResult<Option<f64>>
fn weighted_total(&self) -> LadduDataResult<Option<f64>>
Returns the exact sum of event weights when cheaply available. Read more
Source§fn batches(
&self,
plan: ReadPlan,
) -> LadduDataResult<Box<dyn Iterator<Item = LadduDataResult<EventBatch>> + Send>>
fn batches( &self, plan: ReadPlan, ) -> LadduDataResult<Box<dyn Iterator<Item = LadduDataResult<EventBatch>> + Send>>
Opens a batch iterator using
plan. Read moreSource§impl FragmentedSource for MemorySource
impl FragmentedSource for MemorySource
Source§type Key = MemoryFragmentKey
type Key = MemoryFragmentKey
Source-specific fragment key.
Source§fn fragments(&self) -> LadduDataResult<Vec<DataFragment<Self::Key>>>
fn fragments(&self) -> LadduDataResult<Vec<DataFragment<Self::Key>>>
Lists all fragments in global row order. Read more
Source§fn read_fragment_range(
&self,
key: &Self::Key,
local_start: usize,
local_len: usize,
chunk_size: Option<usize>,
) -> LadduDataResult<Box<dyn Iterator<Item = LadduDataResult<EventBatch>> + Send>>
fn read_fragment_range( &self, key: &Self::Key, local_start: usize, local_len: usize, chunk_size: Option<usize>, ) -> LadduDataResult<Box<dyn Iterator<Item = LadduDataResult<EventBatch>> + Send>>
Reads a contiguous range within one fragment. Read more
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.