pub struct BlockTable {
pub physical_blocks: SmallVec<[BlockId; 8]>,
pub logical_to_physical: SmallVec<[u32; 8]>,
pub sequence_length: usize,
pub block_size: usize,
}Expand description
Block table for mapping logical to physical cache blocks
Fields§
§physical_blocks: SmallVec<[BlockId; 8]>Physical block IDs allocated for this sequence
logical_to_physical: SmallVec<[u32; 8]>Mapping from logical to physical block indices
sequence_length: usizeCurrent sequence length in tokens
block_size: usizeBlock size (tokens per block)
Implementations§
Source§impl BlockTable
impl BlockTable
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Get number of blocks allocated
Sourcepub fn blocks_needed_for_length(length: usize, block_size: usize) -> usize
pub fn blocks_needed_for_length(length: usize, block_size: usize) -> usize
Get required number of blocks for sequence length
Sourcepub fn has_free_space(&self) -> bool
pub fn has_free_space(&self) -> bool
Check if can accommodate more tokens without new blocks
Sourcepub fn free_tokens(&self) -> usize
pub fn free_tokens(&self) -> usize
Get number of free tokens in allocated blocks
Sourcepub fn add_blocks(&mut self, blocks: &[BlockId])
pub fn add_blocks(&mut self, blocks: &[BlockId])
Add blocks to the table
Sourcepub fn extend_sequence(&mut self, additional_tokens: usize) -> Result<()>
pub fn extend_sequence(&mut self, additional_tokens: usize) -> Result<()>
Extend sequence length
Trait Implementations§
Source§impl Clone for BlockTable
impl Clone for BlockTable
Source§fn clone(&self) -> BlockTable
fn clone(&self) -> BlockTable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BlockTable
impl Debug for BlockTable
Source§impl<'de> Deserialize<'de> for BlockTable
impl<'de> Deserialize<'de> for BlockTable
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BlockTable
impl RefUnwindSafe for BlockTable
impl Send for BlockTable
impl Sync for BlockTable
impl Unpin for BlockTable
impl UnsafeUnpin for BlockTable
impl UnwindSafe for BlockTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more