Skip to main content

Cache

Struct Cache 

Source
pub struct Cache { /* private fields */ }
Expand description

LRU cache for kernel matrix rows.

Each of the l data items may have a cached row of length up to l. The cache tracks how much memory (in Qfloat units) is in use and evicts LRU entries when the budget is exceeded.

The LRU list is a circular doubly-linked list using array indices. Index l is the sentinel head node. All operations (insert, remove, evict) are O(1).

Implementations§

Source§

impl Cache

Source

pub fn new(l: usize, size_bytes: usize) -> Self

Create a new cache for l data items with size_bytes of memory.

Source

pub fn get_data( &mut self, index: usize, request_len: usize, ) -> (&mut [Qfloat], usize)

Request data for row index of length request_len.

Returns (data, start) where data is the cached row slice and start is the position from which data needs to be filled. If start >= request_len, the entire row was already cached.

The caller must fill data[start..request_len] with kernel values.

Source

pub fn swap_index(&mut self, i: usize, j: usize)

Swap indices i and j in the cache.

Used by the solver when rearranging the working set.

Auto Trait Implementations§

§

impl Freeze for Cache

§

impl RefUnwindSafe for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

impl UnwindSafe for Cache

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.