Skip to main content

IndexableSource

Trait IndexableSource 

Source
pub trait IndexableSource: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn len_hint(&self) -> Option<usize>;
    fn record_at(&self, idx: usize) -> Result<Option<DataRecord>, SamplerError>;
}
Expand description

Index-addressable source interface used by deterministic pagers.

len_hint must be stable within an epoch, and record_at must return the record corresponding to the same index across runs.

Dense indexing is strongly recommended: implement indices as 0..len_hint with minimal gaps. Sparse indexes (returning None for many positions) still work but waste paging capacity and reduce batch fill rates.

Required Methods§

Source

fn id(&self) -> &str

Stable source identifier.

Source

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

Current index domain size, typically Some(total_records).

Source

fn record_at(&self, idx: usize) -> Result<Option<DataRecord>, SamplerError>

Return the record at index idx, or None for sparse/missing positions.

Implementors§