pub struct Memtable { /* private fields */ }Expand description
Bε-tree-backed memtable, ordered by (RowId, Epoch). A drop-in replacement
for the prototype skip list: the same MVCC semantics with lower write
amplification (buffered messages flush to children in bulk).
Implementations§
Source§impl Memtable
impl Memtable
pub fn new() -> Self
Sourcepub fn upsert(&mut self, row: Row)
pub fn upsert(&mut self, row: Row)
Append a row version (keyed by (row_id, committed_epoch)). Versions are
never overwritten; the newest visible one wins at read time.
Sourcepub fn tombstone(&mut self, row_id: RowId, epoch: Epoch)
pub fn tombstone(&mut self, row_id: RowId, epoch: Epoch)
Append a tombstone version for row_id at epoch. The tombstone copies
the columns from the newest live version so that engine-level HOT cleanup
can recover the primary-key value during WAL replay.
Sourcepub fn get(&self, row_id: RowId, snapshot_epoch: Epoch) -> Option<Row>
pub fn get(&self, row_id: RowId, snapshot_epoch: Epoch) -> Option<Row>
Read the row at row_id visible to snapshot: the newest version with
epoch <= snapshot. Returns None if that version is a tombstone (or no
such version exists).
Sourcepub fn get_version(
&self,
row_id: RowId,
snapshot_epoch: Epoch,
) -> Option<(Epoch, Row)>
pub fn get_version( &self, row_id: RowId, snapshot_epoch: Epoch, ) -> Option<(Epoch, Row)>
Newest version of row_id with epoch <= snapshot, including
tombstones (as a Row with deleted=true). Used by the engine to
merge versions across the memtable and sorted runs.
pub fn is_empty(&self) -> bool
pub fn approx_bytes(&self) -> u64
Sourcepub fn visible_rows(&self, snapshot_epoch: Epoch) -> Vec<Row>
pub fn visible_rows(&self, snapshot_epoch: Epoch) -> Vec<Row>
Visible rows at snapshot, deduplicated to the newest version per
RowId (tombstones drop their row). Returned in ascending RowId order.
Sourcepub fn visible_versions(&self, snapshot_epoch: Epoch) -> Vec<Row>
pub fn visible_versions(&self, snapshot_epoch: Epoch) -> Vec<Row>
Newest visible version per RowId at snapshot, including
tombstones (as Rows with deleted=true). Used by the engine to merge
versions across the memtable and sorted runs.
Sourcepub fn drain_sorted(&mut self) -> Vec<Row>
pub fn drain_sorted(&mut self) -> Vec<Row>
Drain all versions (for a memtable-to-run flush). Returns them in
ascending (RowId, Epoch) order.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Memtable
impl RefUnwindSafe for Memtable
impl Send for Memtable
impl Sync for Memtable
impl Unpin for Memtable
impl UnsafeUnpin for Memtable
impl UnwindSafe for Memtable
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
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