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>;
// Required methods
fn key_bounds(&self) -> Option<(&Self::Key, &Self::Key)>;
fn touched_window_count(&self) -> TouchedWindowCount;
fn negative_weight_count(&self) -> Option<u64>;
// 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.
Required Methods§
Sourcefn key_bounds(&self) -> Option<(&Self::Key, &Self::Key)>
fn key_bounds(&self) -> Option<(&Self::Key, &Self::Key)>
Minimum and maximum keys in this batch.
File-backed batches materialize these bounds at write time. In-memory batches compute them from their ordered key storage. Merge builders use these bounds to decide whether a batch span can be encoded into a roaring bitmap.
Returns None for empty batches.
Sourcefn touched_window_count(&self) -> TouchedWindowCount
fn touched_window_count(&self) -> TouchedWindowCount
Exact number of 16-bit roaring windows touched by the batch, relative to the batch minimum.
File-backed batches materialize this count at write time. In-memory batches track it while they are built. The merge-time filter predictor uses it together with min/max span overlap to estimate how many roaring containers the merged batch will likely touch.
A value of 0 means the batch cannot provide an exact count, e.g. the
key type is not roaring-compatible, the batch span does not fit in
u32, or the batch is empty.
Sourcefn negative_weight_count(&self) -> Option<u64>
fn negative_weight_count(&self) -> Option<u64>
The number of tuples with negative weights in the batch.
This metric is used in merger heuristics. Negative weights are likely to cancel out with positive weights when merging the batch with other batches in the spine; therefore the merger will merge such batches more aggressively than it otherwise would based on the batch size only.
This heuristic is not useful for all batch types, in particular negative weights in batches
produced by recursive queries do not generally cancel out. For such batches we don’t track
negative weights, and this method returns None.
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".