pub struct MemTable<A: AllocatorTrait> { /* private fields */ }
Expand description

In-memory storage for Raft Groups.

Each Raft Group has its own MemTable to store all key value pairs and the file locations of all log entries.

Implementations

Merges with a newer neighbor MemTable.

This method is only used for recovery.

Merges with a MemTable that contains only append data. Assumes self contains all rewritten data of the same region.

This method is only used for recovery.

Returns value for a given key.

Iterates over [start_key, end_key) range and yields all key value pairs as bytes.

Deletes a key value pair.

Puts a key value pair that has been written to the specified file. The old value for this key will be deleted if exists.

Rewrites a key by marking its location to the seq-th log file in rewrite queue. No-op if the key does not exist.

When gate is present, only append data no newer than it will be rewritten.

source

pub fn get_entry(&self, index: u64) -> Option<EntryIndex>

Returns the log entry location for a given logical log index.

Appends some log entries from append queue. Existing entries newer than any of the incoming entries will be deleted silently. Assumes the provided entries have consecutive logical indexes.

Panics

Panics if index of the first entry in entry_indexes is greater than largest existing index + 1 (hole).

Panics if incoming entries contains indexes that might be compacted before (overwrite history).

Appends some entries from append queue. Assumes this table has no rewrite data.

This method is only used for recovery.

Rewrites some entries by modifying their location.

When gate is present, only append data no newer than it will be rewritten.

Panics

Panics if index of the first entry in rewrite_indexes is greater than largest existing rewritten index + 1 (hole).

Appends some entries from rewrite queue. Assumes this table has no append data.

This method is only used for recovery.

Removes all entries with index smaller than index. Returns the number of deleted entries.

Pulls all entries between log index begin and end to the given buffer. Returns error if any entry is missing.

When max_size is present, stops pulling entries when the total size reaches it.

source

pub fn fetch_entry_indexes_before(
    &self,
    gate: FileSeq,
    vec_idx: &mut Vec<EntryIndex>
) -> Result<()>

Pulls all append entries older than or equal to gate, to the provided buffer.

source

pub fn fetch_rewritten_entry_indexes(
    &self,
    vec_idx: &mut Vec<EntryIndex>
) -> Result<()>

Pulls all rewrite entries to the provided buffer.

Pulls all key value pairs older than or equal to gate, to the provided buffer.

Pulls all rewrite key value pairs to the provided buffer.

Returns the smallest file sequence number of entries or key value pairs in this table.

Returns the region ID.

Returns the log index of the first log entry.

Returns the log index of the last log entry.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.