pub struct SuperVersion {
pub version_number: u64,
pub memtable_version: u64,
pub immutable_memtables: Arc<Vec<ImmutableMemTableRef>>,
pub levels: Arc<Vec<LevelMetadata>>,
pub min_snapshot_seqno: u64,
pub log_number: u64,
pub prev_log_number: u64,
pub next_file_number: u64,
pub manifest_file_number: u64,
}Expand description
SuperVersion: A consistent snapshot of all storage metadata
This is the key abstraction for lock-free reads. A SuperVersion contains Arc references to:
- Current mutable memtable
- List of immutable memtables (pending flush)
- All SSTable levels and their file metadata
Readers acquire a SuperVersion (O(1) atomic load), use it for their entire read operation, then release it (O(1) Arc drop). No locks required.
Writers create a new SuperVersion with modified metadata and atomically swap it in. Old versions remain valid until all readers release them.
Fields§
§version_number: u64Version number (monotonically increasing)
memtable_version: u64Current mutable memtable reference Note: The memtable itself may have internal synchronization, but the reference is immutable within a SuperVersion
immutable_memtables: Arc<Vec<ImmutableMemTableRef>>Immutable memtables (oldest first)
levels: Arc<Vec<LevelMetadata>>SSTable levels (L0, L1, L2, …)
min_snapshot_seqno: u64Minimum sequence number safe to garbage collect Versions with seqno < this can be pruned during compaction
log_number: u64Current log (WAL) number for crash recovery
prev_log_number: u64Prev log number (for two-log protocol during flush)
next_file_number: u64Next file number to allocate
manifest_file_number: u64Manifest file number
Implementations§
Source§impl SuperVersion
impl SuperVersion
Sourcepub fn with_new_immutable(&self, imm: ImmutableMemTableRef) -> Self
pub fn with_new_immutable(&self, imm: ImmutableMemTableRef) -> Self
Create a new SuperVersion with updated immutable memtables
Sourcepub fn with_flushed_memtables(
&self,
flushed_ids: &[u64],
new_files: Vec<(u32, Arc<FileMetadata>)>,
) -> Self
pub fn with_flushed_memtables( &self, flushed_ids: &[u64], new_files: Vec<(u32, Arc<FileMetadata>)>, ) -> Self
Create a new SuperVersion after flushing immutable memtables
Sourcepub fn with_compaction_result(
&self,
input_files: &[(u32, u64)],
output_files: Vec<(u32, Arc<FileMetadata>)>,
) -> Self
pub fn with_compaction_result( &self, input_files: &[(u32, u64)], output_files: Vec<(u32, Arc<FileMetadata>)>, ) -> Self
Create a new SuperVersion after compaction
Sourcepub fn total_file_count(&self) -> usize
pub fn total_file_count(&self) -> usize
Get total number of files across all levels
Sourcepub fn pick_compaction_level(&self) -> Option<u32>
pub fn pick_compaction_level(&self) -> Option<u32>
Get level with highest compaction score
Trait Implementations§
Source§impl Clone for SuperVersion
impl Clone for SuperVersion
Source§fn clone(&self) -> SuperVersion
fn clone(&self) -> SuperVersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SuperVersion
impl Debug for SuperVersion
Auto Trait Implementations§
impl !RefUnwindSafe for SuperVersion
impl !UnwindSafe for SuperVersion
impl Freeze for SuperVersion
impl Send for SuperVersion
impl Sync for SuperVersion
impl Unpin for SuperVersion
impl UnsafeUnpin for SuperVersion
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more