Skip to main content

BatchSource

Trait BatchSource 

Source
pub trait BatchSource {
    type Iter: Iterator<Item = Vec<usize>>;

    // Required methods
    fn iter(&self) -> Self::Iter;
    fn epoch(&self) -> u64;
    fn set_epoch(&mut self, epoch: u64);

    // Provided method
    fn exact_len(&self) -> Option<usize> { ... }
}
Expand description

A reusable, epoch-aware source of finite index batches.

Every call to BatchSource::iter creates a fresh iterator. An exact number of batches is optional and is never required for iteration.

Required Associated Types§

Source

type Iter: Iterator<Item = Vec<usize>>

A fresh finite iterator over index batches.

Required Methods§

Source

fn iter(&self) -> Self::Iter

Creates an iterator for the current epoch.

Source

fn epoch(&self) -> u64

Returns the current epoch.

Source

fn set_epoch(&mut self, epoch: u64)

Selects the epoch used by future iterators.

Provided Methods§

Source

fn exact_len(&self) -> Option<usize>

Returns the exact number of batches when it is known.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F, I> BatchSource for FnBatchSource<F>
where F: Fn(u64) -> I, I: Iterator<Item = Vec<usize>>,

Source§

type Iter = I

Source§

impl<S> BatchSource for BatchSampler<S>
where S: Sampler,