Skip to main content

Memtable

Struct Memtable 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn len(&self) -> usize

Number of stored versions.

Source

pub fn is_empty(&self) -> bool

Source

pub fn approx_bytes(&self) -> u64

Source

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.

Source

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.

Source

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§

Source§

impl Default for Memtable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.