diff --git a/libs/layer_map/src/lib.rs b/libs/layer_map/src/lib.rs index f8b36d6452..be8c3069a1 100644 --- a/libs/layer_map/src/lib.rs +++ b/libs/layer_map/src/lib.rs @@ -32,7 +32,7 @@ pub trait InMemoryLayer: std::fmt::Debug + Default + Clone { #[derive(Debug, thiserror::Error)] pub enum GetReconstructPathError {} -pub trait LayerMap { +pub trait HistoricStuff { type Key; type Lsn; type HistoricLayer; @@ -43,40 +43,39 @@ pub trait LayerMap { lsn: Self::Lsn, ) -> Result, GetReconstructPathError>; /// Produce a new version of `self` that includes the given inmem layer. - /// If the layer map is persistent, it is it's job to take care of that. fn make_historic(&self, inmem: Self::InMemoryLayer) -> Self; } -struct State +struct State where K: Copy, - M: LayerMap, + H: HistoricStuff, IML: InMemoryLayer, { inmem: Mutex>, - historic: M, + historic: H, } -pub struct Reader +pub struct Reader where K: Copy, C: seqwait::MonotonicCounter + Copy, L: Ord + Copy, - M: LayerMap, + H: HistoricStuff, IML: InMemoryLayer, { - shared: Wait>>, + shared: Wait>>, } -pub struct ReadWriter +pub struct ReadWriter where K: Copy, C: seqwait::MonotonicCounter + Copy, L: Ord + Copy, - M: LayerMap, + H: HistoricStuff, IML: InMemoryLayer, { - shared: Advance>>, + shared: Advance>>, } pub enum Record { @@ -88,18 +87,18 @@ pub struct Lsn; pub struct PageImage; -pub fn empty( +pub fn empty( lsn: C, - historic: M, + historic: H, ) -> ( - Reader, - ReadWriter, + Reader, + ReadWriter, ) where K: Copy, C: seqwait::MonotonicCounter + Copy, L: Ord + Copy, - M: LayerMap, + H: HistoricStuff, IML: InMemoryLayer, { let state = Arc::new(State { @@ -127,12 +126,12 @@ pub struct ReconstructWork { historic_path: Vec, } -impl Reader +impl Reader where K: Copy, C: seqwait::MonotonicCounter + Copy, L: Ord + Copy, - M: LayerMap, + H: HistoricStuff, IML: InMemoryLayer, { pub async fn get(&self, key: K, lsn: L) -> Result, GetError> { @@ -154,12 +153,12 @@ where } } -impl ReadWriter +impl ReadWriter where K: Copy, C: seqwait::MonotonicCounter + Copy, L: Ord + Copy, - M: LayerMap, + H: HistoricStuff, IML: InMemoryLayer, { pub async fn put(&mut self, key: K, lsn: L, delta: RD) -> tokio::io::Result<()> { @@ -259,7 +258,7 @@ mod tests { } } - impl super::LayerMap for LayerMap { + impl super::HistoricStuff for LayerMap { type Key = usize; type Lsn = usize; type HistoricLayer = Arc;