pub struct L0Manager { /* private fields */ }Implementations§
Source§impl L0Manager
impl L0Manager
pub fn new(start_version: u64, wal: Option<Arc<WriteAheadLog>>) -> Self
Sourcepub fn from_snapshot(
current: Arc<RwLock<L0Buffer>>,
pending_flush: Vec<Arc<RwLock<L0Buffer>>>,
) -> Self
pub fn from_snapshot( current: Arc<RwLock<L0Buffer>>, pending_flush: Vec<Arc<RwLock<L0Buffer>>>, ) -> Self
Create a read-only snapshot L0Manager from existing buffers.
Used by the algorithm execution path to provide L0 visibility without owning the actual L0 lifecycle (rotation, flush, WAL).
Sourcepub fn get_all_readable(&self) -> Vec<Arc<RwLock<L0Buffer>>>
pub fn get_all_readable(&self) -> Vec<Arc<RwLock<L0Buffer>>>
Get all L0 buffers that should be visible to reads. This includes the current L0 plus any L0s being flushed.
Sourcepub fn get_pending_flush(&self) -> Vec<Arc<RwLock<L0Buffer>>>
pub fn get_pending_flush(&self) -> Vec<Arc<RwLock<L0Buffer>>>
Get L0 buffers currently being flushed (for QueryContext).
Sourcepub fn rotate(
&self,
next_version: u64,
new_wal: Option<Arc<WriteAheadLog>>,
) -> Arc<RwLock<L0Buffer>> ⓘ
pub fn rotate( &self, next_version: u64, new_wal: Option<Arc<WriteAheadLog>>, ) -> Arc<RwLock<L0Buffer>> ⓘ
Rotate L0. Returns the OLD L0 buffer.
The new L0 is initialized with next_version and new_wal.
Sourcepub fn begin_flush(
&self,
next_version: u64,
new_wal: Option<Arc<WriteAheadLog>>,
) -> Arc<RwLock<L0Buffer>> ⓘ
pub fn begin_flush( &self, next_version: u64, new_wal: Option<Arc<WriteAheadLog>>, ) -> Arc<RwLock<L0Buffer>> ⓘ
Begin flush: rotate L0 and add old L0 to pending flush list.
The old L0 remains visible to reads until complete_flush is called.
Returns the old L0 buffer to be flushed.
Sourcepub fn complete_flush(&self, l0: &Arc<RwLock<L0Buffer>>)
pub fn complete_flush(&self, l0: &Arc<RwLock<L0Buffer>>)
Complete flush: remove the flushed L0 from pending list. Call this only after L1 writes have succeeded.
Sourcepub fn snapshot_isolated(
&self,
next_version: u64,
new_wal: Option<Arc<WriteAheadLog>>,
) -> (Arc<RwLock<L0Buffer>>, Vec<Arc<RwLock<L0Buffer>>>)
pub fn snapshot_isolated( &self, next_version: u64, new_wal: Option<Arc<WriteAheadLog>>, ) -> (Arc<RwLock<L0Buffer>>, Vec<Arc<RwLock<L0Buffer>>>)
Captures an isolated snapshot of the current L0 (strategy D).
Freezes the current buffer by rotating it aside — writers re-fetch
get_current() at write time, so they move to the fresh buffer and can
never mutate the frozen one — and keeps it readable via the pending
list. Returns the (frozen_main, pending) pair used to build a
QueryContext whose reads are isolated from later writes. Capture is
O(1): one empty-buffer allocation and an Arc move, with no deep copy.
The caller must coordinate with the commit path (e.g. hold the writer’s
flush_lock) so the rotation does not race an in-flight merge into the
current buffer. The frozen generation currently rides the pending-flush
list; a dedicated generation list with reader-count GC is the production
follow-up (see the proposal’s open questions).
Sourcepub fn pin_snapshot(&self) -> SnapshotView
pub fn pin_snapshot(&self) -> SnapshotView
Pins an isolated view of the current L0 tier for a transaction.
O(1): clones the current buffer handle, the pending-flush set, and the
generation’s pin token. No freeze happens here — the current buffer keeps
taking writes; it is frozen aside lazily, and only if still pinned, when a
commit would next mutate it (see Self::freeze_current_for_snapshot and
Self::is_current_pinned). Holds the current read lock across the
buffer and token clones so both come from the same generation even if a
rotate races. Does not require the writer’s flush_lock.
§Examples
let snap = writer.l0_manager().pin_snapshot();
// build a QueryContext from `snap.main` + `snap.extra`Sourcepub fn is_current_pinned(&self) -> bool
pub fn is_current_pinned(&self) -> bool
Returns true if any live SnapshotView pins the current generation.
strong_count > 1 means a snapshot besides the manager holds the token.
Call under the writer’s flush_lock at commit so the decision and any
resulting freeze are atomic with respect to the merge.
Sourcepub fn freeze_current_for_snapshot(&self)
pub fn freeze_current_for_snapshot(&self)
Clones the current (pinned) generation aside so a commit can mutate a
fresh buffer without the pinning snapshots observing the write — lazy
copy-on-write, performed only when Self::is_current_pinned holds.
The outgoing buffer — which the pinning SnapshotViews hold via main
— becomes immutable: a deep copy carrying the same data is installed as
the new current, the commit merges into that copy, and the original is
never mutated again. L0Buffer::clone drops the WAL handle, so the
original’s WAL (already flushed at this commit’s WAL step) is handed to
the copy; the frozen original keeps none, as it takes no more writes. The
original is not placed on the pending-flush list — it is reclaimed by
Arc refcount once the last snapshot drops, so nothing leaks. The new
generation starts unpinned (the pin token is reset). Must be called under
the writer’s flush_lock, since it swaps the current buffer.
Sourcepub fn min_pending_wal_lsn(&self) -> Option<u64>
pub fn min_pending_wal_lsn(&self) -> Option<u64>
Get the minimum WAL LSN across all pending flush L0s. WAL truncation should not go past this LSN to preserve data for pending flushes. Returns None if no pending flushes exist.
Auto Trait Implementations§
impl !Freeze for L0Manager
impl !RefUnwindSafe for L0Manager
impl !UnwindSafe for L0Manager
impl Send for L0Manager
impl Sync for L0Manager
impl Unpin for L0Manager
impl UnsafeUnpin for L0Manager
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> PluginState for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.