Skip to main content

Batch

Trait Batch 

Source
pub trait Batch:
    BatchReader
    + Clone
    + Send
    + Sync
where 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§

Source

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.

Source

type Batcher: Batcher<Self>

A type used to assemble batches from disordered updates.

Source

type Builder: Builder<Self>

A type used to assemble batches from ordered update sequences.

Provided Methods§

Source

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.

Source

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>,

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.

Source

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>,

Like from_batch, but avoids cloning the batch if the output type is identical to the input type.

Source

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>,

Creates a new batch as a copy of the tuples accessible via cursor``, using timestamp` for all of the new batch’s timestamps.

Source

fn dyn_empty(factories: &Self::Factories) -> Self

Creates an empty batch.

Source

fn filter(&self, predicate: &dyn Fn(&Self::Key, &Self::Val) -> bool) -> Self
where Self::Time: PartialEq<()> + From<()>,

Returns elements from self that satisfy a predicate.

Source

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.

Source

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.

Source

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.

Implementors§

Source§

impl<K, R> Batch for FallbackWSet<K, R>
where K: DataTrait + ?Sized, R: WeightTrait + ?Sized,

Source§

impl<K, R> Batch for FileWSet<K, R>
where K: DataTrait + ?Sized, R: WeightTrait + ?Sized,

Source§

impl<K, T, R> Batch for FallbackKeyBatch<K, T, R>
where K: DataTrait + ?Sized, T: Timestamp, R: WeightTrait + ?Sized,

Source§

impl<K, T, R> Batch for FileKeyBatch<K, T, R>
where K: DataTrait + ?Sized, T: Timestamp, R: WeightTrait + ?Sized,

Source§

impl<K, T, R, O> Batch for VecKeyBatch<K, T, R, O>
where K: DataTrait + ?Sized, T: Timestamp, R: WeightTrait + ?Sized, O: OrdOffset,

Source§

type Timed<T2: Timestamp> = VecKeyBatch<K, T2, R, O>

Source§

type Batcher = MergeBatcher<VecKeyBatch<K, T, R, O>>

Source§

type Builder = VecKeyBuilder<K, T, R, O>

Source§

impl<K, V, R> Batch for FallbackIndexedWSet<K, V, R>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, R: WeightTrait + ?Sized,

Source§

impl<K, V, R> Batch for FileIndexedWSet<K, V, R>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, R: WeightTrait + ?Sized,

Source§

impl<K, V, R, O> Batch for VecIndexedWSet<K, V, R, O>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, R: WeightTrait + ?Sized, O: OrdOffset,

Source§

impl<K, V, T, R> Batch for FallbackValBatch<K, V, T, R>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, T: Timestamp, R: WeightTrait + ?Sized,

Source§

impl<K, V, T, R> Batch for FileValBatch<K, V, T, R>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, T: Timestamp, R: WeightTrait + ?Sized,

Source§

type Timed<T2: Timestamp> = FileValBatch<K, V, T2, R>

Source§

type Batcher = MergeBatcher<FileValBatch<K, V, T, R>>

Source§

type Builder = FileValBuilder<K, V, T, R>

Source§

impl<K, V, T, R, O> Batch for VecValBatch<K, V, T, R, O>
where K: DataTrait + ?Sized, V: DataTrait + ?Sized, R: WeightTrait + ?Sized, T: Timestamp, O: OrdOffset,

Source§

type Timed<T2: Timestamp> = VecValBatch<K, V, T2, R, O>

Source§

type Batcher = MergeBatcher<VecValBatch<K, V, T, R, O>>

Source§

type Builder = VecValBuilder<K, V, T, R, O>

Source§

impl<K: DataTrait + ?Sized, R: WeightTrait + ?Sized> Batch for VecWSet<K, R>