pub struct VersionChain { /* private fields */ }Expand description
Chain of versions for a single key, sorted by commit_ts descending
Optimized for:
- O(log V) reads via binary search
- O(1) writes (prepend to front)
- O(V) GC (linear scan with compaction)
Implementations§
Source§impl VersionChain
impl VersionChain
Sourcepub fn add_uncommitted(
&mut self,
value: Option<Vec<u8>>,
txn_id: u64,
epoch: u32,
)
pub fn add_uncommitted( &mut self, value: Option<Vec<u8>>, txn_id: u64, epoch: u32, )
Add uncommitted version
Sourcepub fn commit(&mut self, txn_id: u64, commit_ts: u64) -> bool
pub fn commit(&mut self, txn_id: u64, commit_ts: u64) -> bool
Commit the uncommitted version
Returns true if committed successfully
Sourcepub fn read_at(
&self,
snapshot_ts: u64,
current_txn_id: Option<u64>,
) -> Option<&VersionEntry>
pub fn read_at( &self, snapshot_ts: u64, current_txn_id: Option<u64>, ) -> Option<&VersionEntry>
Read at snapshot timestamp
Returns the most recent version visible at snapshot_ts. If current_txn_id is provided, also considers uncommitted writes from that txn.
Complexity: O(log V) via binary search
Sourcepub fn has_write_conflict(&self, my_txn_id: u64) -> bool
pub fn has_write_conflict(&self, my_txn_id: u64) -> bool
Check if there’s a write conflict
Trait Implementations§
Source§impl Debug for VersionChain
impl Debug for VersionChain
Source§impl Default for VersionChain
impl Default for VersionChain
Source§fn default() -> VersionChain
fn default() -> VersionChain
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for VersionChain
impl RefUnwindSafe for VersionChain
impl Send for VersionChain
impl Sync for VersionChain
impl Unpin for VersionChain
impl UnwindSafe for VersionChain
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> 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>
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