pub trait Batch:
BatchReader
+ Clone
+ Send
+ Syncwhere
Self: Sized,{
type Timed<T: Timestamp>: Batch<Key = <Self as BatchReader>::Key, Val = <Self as BatchReader>::Val, Time = T, R = <Self as BatchReader>::R>;
type Batcher: Batcher<Self>;
type Builder: Builder<Self>;
// Provided methods
fn dyn_from_tuples(
factories: &Self::Factories,
time: Self::Time,
tuples: &mut Box<DynWeightedPairs<DynPair<Self::Key, Self::Val>, Self::R>>,
) -> Self { ... }
fn from_batch<BI>(
batch: &BI,
timestamp: &Self::Time,
factories: &Self::Factories,
) -> Self
where BI: BatchReader<Key = Self::Key, Val = Self::Val, Time = (), R = Self::R> { ... }
fn from_arc_batch<BI>(
batch: &Arc<BI>,
timestamp: &Self::Time,
factories: &Self::Factories,
) -> Arc<Self>
where BI: BatchReader<Key = Self::Key, Val = Self::Val, Time = (), R = Self::R> { ... }
fn from_cursor<C>(
cursor: C,
timestamp: &Self::Time,
factories: &Self::Factories,
key_capacity: usize,
value_capacity: usize,
) -> Self
where C: Cursor<Self::Key, Self::Val, (), Self::R> { ... }
fn dyn_empty(factories: &Self::Factories) -> Self { ... }
fn filter(&self, predicate: &dyn Fn(&Self::Key, &Self::Val) -> bool) -> Self
where Self::Time: PartialEq<()> + From<()> { ... }
fn persisted(&self) -> Option<Self> { ... }
fn file_reader(&self) -> Option<Arc<dyn FileReader>> { ... }
fn from_path(
_factories: &Self::Factories,
_path: &StoragePath,
) -> Result<Self, ReaderError> { ... }
}Expand description
A BatchReader plus features for constructing new batches.
Batch extends BatchReader with types for constructing new batches
from ordered tuples (Self::Builder) or unordered tuples
(Self::Batcher), or by merging traces of like types, plus some
convenient methods for using those types.
See crate documentation for more information on batches and traces.
Required Associated Types§
Sourcetype Timed<T: Timestamp>: Batch<Key = <Self as BatchReader>::Key, Val = <Self as BatchReader>::Val, Time = T, R = <Self as BatchReader>::R>
type Timed<T: Timestamp>: Batch<Key = <Self as BatchReader>::Key, Val = <Self as BatchReader>::Val, Time = T, R = <Self as BatchReader>::R>
A batch type equivalent to Self, but with timestamp type T instead of Self::Time.
Provided Methods§
Sourcefn dyn_from_tuples(
factories: &Self::Factories,
time: Self::Time,
tuples: &mut Box<DynWeightedPairs<DynPair<Self::Key, Self::Val>, Self::R>>,
) -> Self
fn dyn_from_tuples( factories: &Self::Factories, time: Self::Time, tuples: &mut Box<DynWeightedPairs<DynPair<Self::Key, Self::Val>, Self::R>>, ) -> Self
Assemble an unordered vector of weighted items into a batch.
Sourcefn from_batch<BI>(
batch: &BI,
timestamp: &Self::Time,
factories: &Self::Factories,
) -> Self
fn from_batch<BI>( batch: &BI, timestamp: &Self::Time, factories: &Self::Factories, ) -> Self
Creates a new batch as a copy of batch, using timestamp for all of
the new batch’s timestamps This is useful for adding a timestamp to a
batch, or for converting between different batch implementations
(e.g. writing an in-memory batch to disk).
TODO: for adding a timestamp to a batch, this could be implemented more efficiently by having a special batch type where all updates have the same timestamp, as this is the only kind of batch that we ever create directly in DBSP; batches with multiple timestamps are only created as a result of merging. The main complication is that we will need to extend the trace implementation to work with batches of multiple types. This shouldn’t be too hard and is on the todo list.
Sourcefn from_arc_batch<BI>(
batch: &Arc<BI>,
timestamp: &Self::Time,
factories: &Self::Factories,
) -> Arc<Self>
fn from_arc_batch<BI>( batch: &Arc<BI>, timestamp: &Self::Time, factories: &Self::Factories, ) -> Arc<Self>
Like from_batch, but avoids cloning the batch if the output type is identical to the input type.
Sourcefn from_cursor<C>(
cursor: C,
timestamp: &Self::Time,
factories: &Self::Factories,
key_capacity: usize,
value_capacity: usize,
) -> Self
fn from_cursor<C>( cursor: C, timestamp: &Self::Time, factories: &Self::Factories, key_capacity: usize, value_capacity: usize, ) -> Self
Creates a new batch as a copy of the tuples accessible via cursor``, using timestamp` for all of the new batch’s timestamps.
Sourcefn filter(&self, predicate: &dyn Fn(&Self::Key, &Self::Val) -> bool) -> Self
fn filter(&self, predicate: &dyn Fn(&Self::Key, &Self::Val) -> bool) -> Self
Returns elements from self that satisfy a predicate.
Sourcefn persisted(&self) -> Option<Self>
fn persisted(&self) -> Option<Self>
If this batch is not on storage, but supports writing itself to storage, this method writes it to storage and returns the stored version.
Sourcefn file_reader(&self) -> Option<Arc<dyn FileReader>>
fn file_reader(&self) -> Option<Arc<dyn FileReader>>
This functions returns the file that can be used to restore the batch’s contents.
If the batch can not be persisted, this function returns None.
fn from_path( _factories: &Self::Factories, _path: &StoragePath, ) -> Result<Self, ReaderError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.