pub struct BlockTable { /* private fields */ }Expand description
Maps a sequence’s logical block indices to physical page indices.
Each transformer layer has its own independent list of physical blocks so that cross-layer sharing is straightforward to reason about.
Implementations§
Source§impl BlockTable
impl BlockTable
Sourcepub fn new(num_layers: usize, block_size: usize) -> Self
pub fn new(num_layers: usize, block_size: usize) -> Self
Create an empty block table for num_layers layers.
Sourcepub fn append_block(&mut self, layer: usize, physical_idx: usize)
pub fn append_block(&mut self, layer: usize, physical_idx: usize)
Append a newly-allocated physical page to layer’s block list.
§Panics
Panics in debug builds if layer >= num_layers.
Sourcepub fn get_block(&self, layer: usize, logical_block: usize) -> Option<usize>
pub fn get_block(&self, layer: usize, logical_block: usize) -> Option<usize>
Look up the physical page index for logical block logical_block in
layer.
Returns None if either the layer or the logical block index is out of
range.
Sourcepub fn num_blocks(&self, layer: usize) -> usize
pub fn num_blocks(&self, layer: usize) -> usize
Number of physical blocks currently mapped for layer.
Returns 0 for out-of-range layer.
Sourcepub fn token_capacity(&self, layer: usize) -> usize
pub fn token_capacity(&self, layer: usize) -> usize
Total token capacity (may include unused trailing slots) for layer.
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more