pub struct ValueLog { /* private fields */ }Expand description
Value log for storing large values
Implementations§
Source§impl ValueLog
impl ValueLog
Sourcepub fn new(vlog_dir: impl AsRef<Path>) -> Result<Self>
pub fn new(vlog_dir: impl AsRef<Path>) -> Result<Self>
Create a new value log with default configuration
Sourcepub fn with_config(config: ValueLogConfig) -> Result<Self>
pub fn with_config(config: ValueLogConfig) -> Result<Self>
Create a new value log with custom configuration
Sourcepub fn with_config_and_gc(
config: ValueLogConfig,
gc_config: GcConfig,
) -> Result<Self>
pub fn with_config_and_gc( config: ValueLogConfig, gc_config: GcConfig, ) -> Result<Self>
Create a new value log with custom configuration and GC configuration
Sourcepub fn should_separate(&self, value: &CipherBlob) -> bool
pub fn should_separate(&self, value: &CipherBlob) -> bool
Check if a value should be stored in vLog
Sourcepub fn append(&self, key: Key, value: CipherBlob) -> Result<ValuePointer>
pub fn append(&self, key: Key, value: CipherBlob) -> Result<ValuePointer>
Append a value to the vLog and return a pointer
Sourcepub fn read(&self, pointer: &ValuePointer) -> Result<CipherBlob>
pub fn read(&self, pointer: &ValuePointer) -> Result<CipherBlob>
Read a value from the vLog using a pointer
Sourcepub fn current_file_id(&self) -> u64
pub fn current_file_id(&self) -> u64
Get current file ID
Sourcepub fn config(&self) -> &ValueLogConfig
pub fn config(&self) -> &ValueLogConfig
Get configuration
Sourcepub fn last_write_time_millis(&self) -> u64
pub fn last_write_time_millis(&self) -> u64
Get the timestamp (millis since UNIX epoch) of the last write operation
Sourcepub fn time_since_last_write(&self) -> Duration
pub fn time_since_last_write(&self) -> Duration
Get the duration since the last write operation
Source§impl ValueLog
GC-related methods for ValueLog
impl ValueLog
GC-related methods for ValueLog
Sourcepub fn mark_dead(&self, pointer: &ValuePointer)
pub fn mark_dead(&self, pointer: &ValuePointer)
Mark a value as dead/stale in segment stats
This should be called when a key is overwritten or deleted, invalidating the old value in the vLog.
Sourcepub fn dead_ratio(&self, file_id: u64) -> f64
pub fn dead_ratio(&self, file_id: u64) -> f64
Get the dead ratio for a given segment (file_id)
Returns dead_bytes / total_bytes, or 0.0 if the segment has no data.
Sourcepub fn segment_stats(&self, file_id: u64) -> Option<SegmentStats>
pub fn segment_stats(&self, file_id: u64) -> Option<SegmentStats>
Get a copy of the segment stats for a given file_id
Sourcepub fn is_gc_running(&self) -> bool
pub fn is_gc_running(&self) -> bool
Check if GC is currently running
Sourcepub fn total_reclaimable_bytes(&self) -> u64
pub fn total_reclaimable_bytes(&self) -> u64
Get total reclaimable bytes across all segments
Sourcepub fn collect_garbage<F>(&self, is_live_fn: F) -> Result<GcResult>
pub fn collect_garbage<F>(&self, is_live_fn: F) -> Result<GcResult>
Collect garbage across all eligible segments
Finds segments exceeding the dead ratio threshold and old enough, then rewrites live entries to new segments and deletes old ones.
is_live_fn: Function that checks if a key is still live in the LSM-Tree.
The function receives the key and should return true if the key’s current
value pointer still points to this entry.
Sourcepub fn reclaim_segment<F>(
&self,
file_id: u64,
is_live_fn: &F,
) -> Result<(u64, u64)>
pub fn reclaim_segment<F>( &self, file_id: u64, is_live_fn: &F, ) -> Result<(u64, u64)>
Reclaim a single segment by rewriting live entries to the active segment
Returns (bytes_reclaimed, entries_rewritten) on success.
Sourcepub fn garbage_collect_file<F>(
&self,
file_id: u64,
is_live_fn: F,
) -> Result<GcStats>
pub fn garbage_collect_file<F>( &self, file_id: u64, is_live_fn: F, ) -> Result<GcStats>
Perform garbage collection on a vLog file
Scans the file and rewrites live values to a new file, discarding dead values. This is typically called when a file has too much garbage.
is_live_fn: Function that checks if a key is still live in the LSM-Tree
Auto Trait Implementations§
impl Freeze for ValueLog
impl !RefUnwindSafe for ValueLog
impl Send for ValueLog
impl Sync for ValueLog
impl Unpin for ValueLog
impl UnsafeUnpin for ValueLog
impl !UnwindSafe for ValueLog
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
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>
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.