pub struct ExecutionFrame<'a> { /* private fields */ }Expand description
An isolated write arena scoped to a single block.
Writes appended through an ExecutionFrame go into the active log immediately
(making them durable on fsync) but are not visible to DonaDbX::get()
until the frame is committed and the subsequent fold pass updates the index.
Use abort() to roll back all writes made since the
frame was created, as if they never happened. Use
commit() to promote them into the committed log.
Implementations§
Source§impl<'a> ExecutionFrame<'a>
impl<'a> ExecutionFrame<'a>
Sourcepub fn put(&self, key: [u8; 32], value: &[u8]) -> DbResult<u64>
pub fn put(&self, key: [u8; 32], value: &[u8]) -> DbResult<u64>
Append a key-value pair within this frame.
Identical semantics to DonaDbX::put(): lock-free, one fetch_add,
one memcpy. The write is not reflected in DonaDbX::get() until
this frame is committed and the fold completes.
Sourcepub fn commit(self, height: u64) -> DbResult<CommitAck>
pub fn commit(self, height: u64) -> DbResult<CommitAck>
Commit all writes in this frame for block height.
Equivalent to calling DonaDbX::commit() directly. The frame is
consumed and its writes become visible to readers after the fold
completes.
Sourcepub fn abort(self)
pub fn abort(self)
Abort this frame, rolling back all writes made since it was created.
Zero-fills the log region from start to the current write offset,
then resets the write offset to start. This makes the region
available for reuse and leaves no trace in the log.
If a segment rotation occurred after this frame was opened (detected
by comparing the stored log_id with the current generation), the
frame has already been sealed into a segment. In that case the abort
is a no-op: the rotation’s committed-offset boundary already excludes
any partial writes from this frame.
The method waits for all in-flight lock-free writes (those that reserved space but have not yet finished copying) to complete before zeroing, to avoid a data race with concurrent writers in the same shard.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ExecutionFrame<'a>
impl<'a> !UnwindSafe for ExecutionFrame<'a>
impl<'a> Freeze for ExecutionFrame<'a>
impl<'a> Send for ExecutionFrame<'a>
impl<'a> Sync for ExecutionFrame<'a>
impl<'a> Unpin for ExecutionFrame<'a>
impl<'a> UnsafeUnpin for ExecutionFrame<'a>
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> 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