Skip to main content

SyntheticCachePager

Struct SyntheticCachePager 

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

In-memory CachePager used by every test in this crate and by examples/02-twelve-way-parallel/ (when that lands).

Stores pages in a BTreeMap<u32, PageBytes> keyed by physical-page index. allocate_pages returns monotonically increasing indices; write_page inserts; read_page reads.

Clone-able — the inner state is Arc<Mutex<…>> so two clones share the same logical engine. Useful for “fork the in-memory engine; mutate one branch; serialize each; assert dedup.”

Implementations§

Source§

impl SyntheticCachePager

Source

pub fn new(meta: CacheMeta) -> Self

Construct an empty engine with the given static metadata.

Source

pub fn populate_synthetic(&mut self, n_pages: u32, seed: u64) -> Result<()>

Pre-populate the engine with n_pages deterministic pages and one logical sequence covering them all. Useful for tests / benches.

seed mixes into the per-page fill so different seeds produce different pages (driving CAS divergence) while the same seed produces byte-identical pages (driving CAS dedup).

Trait Implementations§

Source§

impl CachePager for SyntheticCachePager

Source§

fn meta(&self) -> CacheMeta

Static cache metadata (page size, layer count, dtype, …).
Source§

fn pause(&mut self) -> Result<()>

Pause the engine so the page table is stable. May be a no-op for adapters that already hold a write-lock during snapshot.
Source§

fn resume(&mut self) -> Result<()>

Resume the engine after pause / restore.
Source§

fn occupied_pages(&self) -> Vec<u32>

List physical-page indices that currently hold valid data.
Source§

fn logical_seqs(&self) -> Vec<LogicalSeq>

Snapshot of every live logical sequence’s page-table mapping.
Source§

fn read_page(&self, ix: u32) -> Result<PageBytes>

Read one (K, V) page out of the engine. Implementations return raw bytes of length meta.page_bytes() for each.
Source§

fn allocate_pages(&mut self, n: usize) -> Result<Vec<u32>>

Allocate n fresh physical-page slots and return their indices in the order they should be filled. Restore writes pages in this order.
Source§

fn write_page(&mut self, ix: u32, page: &PageBytes) -> Result<()>

Write one (K, V) page into the engine at the given physical-page index. The index MUST have been returned by a recent Self::allocate_pages call.
Source§

fn install_logical_seqs(&mut self, seqs: &[LogicalSeq]) -> Result<()>

Re-install the per-request logical-seq → page-list mapping after restore. Called once, after all pages have been written.
Source§

impl Clone for SyntheticCachePager

Source§

fn clone(&self) -> SyntheticCachePager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntheticCachePager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.