pub struct CachedSource<S> { /* private fields */ }Expand description
StateSource を包み、読んだ行と木のノード(なかったことも)を覚えておくキャッシュ。要るものだけを読む
super::Executor は、ブロックをコミットするたびに読み込んだものを手放す
(super::Executor::release_loaded)ので、ブロックをまたいで持っておくのはここだけになる。
覚える量は、キーと値のバイト数で決め、超えたら長く使っていないものから捨てる。コミットで変わった行と
ノードは CachedSource::record で、巻き戻したら CachedSource::clear で伝える。前方一致の走査
(StateSource::for_each_row)は覚えずに、包んだ読み口にそのまま渡す。
Implementations§
Source§impl<S> CachedSource<S>
impl<S> CachedSource<S>
pub fn inner(&self) -> &S
Sourcepub fn inner_mut(&mut self) -> &mut S
pub fn inner_mut(&mut self) -> &mut S
包んだ読み口を変えるときに使う。変えた行とノードは CachedSource::record で伝えること
pub fn into_inner(self) -> S
Sourcepub fn record(
&self,
rows: impl IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>,
nodes: impl IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>,
)
pub fn record( &self, rows: impl IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>, nodes: impl IntoIterator<Item = (Vec<u8>, Option<Vec<u8>>)>, )
コミットで変わった行(super::persist::row_key)と木のノード(crate::tree::node_key)。None は消えた。
覚えているものは新しい値にし、覚えていないものも、すぐまた読まれやすいので覚える
pub fn stats(&self) -> CacheStats
Trait Implementations§
Auto Trait Implementations§
impl<S> !Freeze for CachedSource<S>
impl<S> RefUnwindSafe for CachedSource<S>where
S: RefUnwindSafe,
impl<S> Send for CachedSource<S>where
S: Send,
impl<S> Sync for CachedSource<S>where
S: Sync,
impl<S> Unpin for CachedSource<S>where
S: Unpin,
impl<S> UnsafeUnpin for CachedSource<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for CachedSource<S>where
S: UnwindSafe,
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> 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