Trait pagecache::Materializer
source · pub trait Materializer {
type PageFrag;
type Recovery;
fn new(config: Config, recovered_state: &Option<Self::Recovery>) -> Self
where
Self: Sized;
fn merge(&self, frags: &[&Self::PageFrag]) -> Self::PageFrag;
fn recover(&self, frag: &Self::PageFrag) -> Option<Self::Recovery>;
fn size_in_bytes(&self, frag: &Self::PageFrag) -> usize;
}
Expand description
A user of a PageCache
needs to provide a Materializer
which
handles the merging of page fragments.
Required Associated Types
Required Methods
sourcefn new(config: Config, recovered_state: &Option<Self::Recovery>) -> Selfwhere
Self: Sized,
fn new(config: Config, recovered_state: &Option<Self::Recovery>) -> Selfwhere
Self: Sized,
Create a new Materializer
with the previously recovered
state if any existed.
sourcefn merge(&self, frags: &[&Self::PageFrag]) -> Self::PageFrag
fn merge(&self, frags: &[&Self::PageFrag]) -> Self::PageFrag
Used to merge chains of partial pages into a form
that is useful for the PageCache
owner.
sourcefn recover(&self, frag: &Self::PageFrag) -> Option<Self::Recovery>
fn recover(&self, frag: &Self::PageFrag) -> Option<Self::Recovery>
Used to feed custom recovery information back to a higher-level abstraction during startup. For example, a B-Link tree must know what the current root node is before it can start serving requests.
sourcefn size_in_bytes(&self, frag: &Self::PageFrag) -> usize
fn size_in_bytes(&self, frag: &Self::PageFrag) -> usize
Used to determine the size of the value for caching purposes.