Skip to main content

Memtable

Struct Memtable 

Source
pub struct Memtable { /* private fields */ }
Expand description

In-memory write buffer

Stores mutations in memory with token-based ordering. Each partition can have multiple mutations (e.g., multiple rows with different clustering keys).

Implementations§

Source§

impl Memtable

Source

pub fn new() -> Self

Create a new memtable

Source

pub fn insert(&mut self, _mutation: Mutation) -> Result<()>

Insert a mutation into the memtable

Mutations are grouped by partition key (DecoratedKey). Multiple mutations for the same partition are stored as a vector.

Source

pub fn insert_with_key( &mut self, key: DecoratedKey, mutation: Mutation, ) -> Result<()>

Insert a mutation with an explicit decorated key

This is the primary insertion API. The caller is responsible for computing the decorated key from the partition key using the table schema.

Source

pub fn get(&self, key: &DecoratedKey) -> Option<&[Mutation]>

Get all mutations for a given partition key

Source

pub fn is_empty(&self) -> bool

Check if memtable is empty

Source

pub fn size_bytes(&self) -> usize

Get current size in bytes (approximate)

Source

pub fn row_count(&self) -> usize

Get approximate row count

Source

pub fn should_flush(&self, threshold_bytes: usize) -> bool

Check if memtable should be flushed

Source

pub fn created_at(&self) -> i64

Get creation timestamp (microseconds since Unix epoch)

Source

pub fn iter(&self) -> impl Iterator<Item = (&DecoratedKey, &[Mutation])>

Iterate over all partitions and their mutations

Returns an iterator over (DecoratedKey, mutations) pairs in token order.

Source

pub fn clear(&mut self)

Clear all data from the memtable

Used after successful flush to SSTable.

Trait Implementations§

Source§

impl Debug for Memtable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.