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
impl Memtable
Sourcepub fn insert(&mut self, _mutation: Mutation) -> Result<()>
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.
Sourcepub fn insert_with_key(
&mut self,
key: DecoratedKey,
mutation: Mutation,
) -> Result<()>
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.
Sourcepub fn get(&self, key: &DecoratedKey) -> Option<&[Mutation]>
pub fn get(&self, key: &DecoratedKey) -> Option<&[Mutation]>
Get all mutations for a given partition key
Sourcepub fn size_bytes(&self) -> usize
pub fn size_bytes(&self) -> usize
Get current size in bytes (approximate)
Sourcepub fn should_flush(&self, threshold_bytes: usize) -> bool
pub fn should_flush(&self, threshold_bytes: usize) -> bool
Check if memtable should be flushed
Sourcepub fn created_at(&self) -> i64
pub fn created_at(&self) -> i64
Get creation timestamp (microseconds since Unix epoch)
Sourcepub fn iter(&self) -> impl Iterator<Item = (&DecoratedKey, &[Mutation])>
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.