Skip to main content

BatchExt

Trait BatchExt 

Source
pub trait BatchExt: Indicator {
    // Provided methods
    fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
       where Self::Input: Clone { ... }
    fn batch_parallel<F>(
        inputs_per_asset: &[Vec<Self::Input>],
        make: F,
    ) -> Vec<Vec<Option<Self::Output>>>
       where Self: Sized + Send,
             Self::Input: Sync + Clone,
             Self::Output: Send,
             F: Fn() -> Self + Sync + Send { ... }
}
Expand description

Blanket extension that adds batch evaluation to every Indicator.

The naive batch simply replays update over a slice, which is always correct because update is the only state transition. Concrete indicators may override batch if they have a faster vectorized path; the default keeps the contract batch == repeated update.

Provided Methods§

Source

fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
where Self::Input: Clone,

Run the indicator over a slice of inputs in order, returning one output (or None during warmup) per input.

Source

fn batch_parallel<F>( inputs_per_asset: &[Vec<Self::Input>], make: F, ) -> Vec<Vec<Option<Self::Output>>>
where Self: Sized + Send, Self::Input: Sync + Clone, Self::Output: Send, F: Fn() -> Self + Sync + Send,

Available on crate feature parallel only.

Run an independent copy of the indicator over each input series in parallel.

Each asset is processed by its own fresh instance built via make, so state never leaks across assets. Requires the parallel feature (enabled by default), which pulls in rayon.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§