pub struct Memtable { /* private fields */ }Expand description
Structurally shared committed overlays plus one small mutable write delta.
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). Legacy epoch-only entry
point; prefer Self::get_version_at when the caller holds a full
crate::epoch::Snapshot.
Sourcepub fn get_version_at(
&self,
row_id: RowId,
snapshot: Snapshot,
) -> Option<(Epoch, Row)>
pub fn get_version_at( &self, row_id: RowId, snapshot: Snapshot, ) -> Option<(Epoch, Row)>
Newest version of row_id visible under snapshot (including
tombstones). Uses HLC authority when stamps are present (P0.5-T3).
Seeks each segment’s composite-key range for row_id so dual-model
mixes (stamped + unstamped) and HLC/epoch order inversions stay correct
without materializing every version in the memtable.
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.
pub fn visible_versions_at(&self, snapshot: Snapshot) -> Vec<Row>
pub fn newest_visible_iter<'a>( &'a self, snapshot: &Snapshot, ) -> MemtableVisibleVersionCursor<'a> ⓘ
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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