pub trait ExpertSource: Sync {
// Required methods
fn slot_layout(&self) -> SlotLayout;
fn num_experts(&self) -> usize;
fn read_expert(&self, layer: u32, expert: u32, dst: &mut [u8]) -> Result<()>;
// Provided methods
fn read_expert_range(
&self,
layer: u32,
expert: u32,
off: usize,
dst: &mut [u8],
) -> Result<()> { ... }
fn direct_segments(
&self,
layer: u32,
expert: u32,
) -> Result<Option<Vec<DirectSeg>>> { ... }
fn direct_file(&self, shard: usize) -> Option<&File> { ... }
}Expand description
Anything the LRU can fill a slot from. The on-disk map implements it; the unit tests implement it in memory.
Required Methods§
fn slot_layout(&self) -> SlotLayout
fn num_experts(&self) -> usize
Provided Methods§
Sourcefn read_expert_range(
&self,
layer: u32,
expert: u32,
off: usize,
dst: &mut [u8],
) -> Result<()>
fn read_expert_range( &self, layer: u32, expert: u32, off: usize, dst: &mut [u8], ) -> Result<()>
Fill dst with bytes off..off + dst.len() of the expert’s slot
image, so one miss can be read by several threads at once. The
default reads the whole expert into scratch; the on-disk map seeks.
Sourcefn direct_segments(
&self,
layer: u32,
expert: u32,
) -> Result<Option<Vec<DirectSeg>>>
fn direct_segments( &self, layer: u32, expert: u32, ) -> Result<Option<Vec<DirectSeg>>>
The expert’s slot image as file ranges for O_DIRECT reads, or
None when this source has no direct descriptor (the default): the
staged miss path then reads through read_expert_range.
Sourcefn direct_file(&self, shard: usize) -> Option<&File>
fn direct_file(&self, shard: usize) -> Option<&File>
The O_DIRECT descriptor a DirectSeg names.