MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
MemTable implementation for LSM-Tree. 更多...
#include <ob_memtable.h>
类 | |
struct | KeyComparator |
Compares two keys. 更多... | |
Public 成员函数 | |
shared_ptr< ObMemTable > | get_shared_ptr () |
Retrieves a shared pointer to the current ObMemTable instance. 更多... | |
void | put (uint64_t seq, const string_view &key, const string_view &value) |
Inserts a key-value pair into the memtable. 更多... | |
size_t | appro_memory_usage () const |
Estimates the memory usage of the memtable. 更多... | |
ObLsmIterator * | new_iterator () |
Creates a new iterator for traversing the contents of the memtable. 更多... | |
Private 类型 | |
typedef ObSkipList< const char *, KeyComparator > | Table |
Private 属性 | |
KeyComparator | comparator_ |
Comparator used for ordering keys in the memtable. 更多... | |
Table | table_ |
The underlying data structure used for key-value storage. 更多... | |
ObArena | arena_ |
Memory arena used for memory management in the memtable. 更多... | |
友元 | |
class | ObMemTableIterator |
MemTable implementation for LSM-Tree.
The ObMemTable
represents an in-memory structure that stores key-value pairs before they are flushed to disk as SSTables. It supports key-value insertion, querying, and iteration. The implementation currently uses a skip list as the underlying data structure.
|
inline |
Estimates the memory usage of the memtable.
Returns the approximate memory usage of the memtable, including the skip list and associated memory allocations.
|
inline |
Retrieves a shared pointer to the current ObMemTable instance.
This method utilizes std::enable_shared_from_this
to provide a shared pointer to the current object. Useful when the current object needs to be shared safely among multiple components.
ObMemTable
instance. ObLsmIterator * oceanbase::ObMemTable::new_iterator | ( | ) |
Creates a new iterator for traversing the contents of the memtable.
This method returns a heap-allocated iterator for iterating over key-value pairs stored in the memtable. The caller is responsible for managing the lifetime of the returned iterator.
ObLsmIterator
for the memtable. void oceanbase::ObMemTable::put | ( | uint64_t | seq, |
const string_view & | key, | ||
const string_view & | value | ||
) |
Inserts a key-value pair into the memtable.
Each entry is versioned using the provided seq
number. If the same key is inserted multiple times, the version with the highest sequence number will take precedence when queried.
seq | A sequence number used for versioning the key-value entry. |
key | The key to be inserted. |
value | The value associated with the key. |
|
private |
Memory arena used for memory management in the memtable.
Allocates and tracks memory usage for the skip list and other internal components of the memtable.
|
private |
Comparator used for ordering keys in the memtable.
This member defines the rules for comparing keys in the skip list. TODO: support user-defined comparator
|
private |
The underlying data structure used for key-value storage.
Currently implemented as a skip list. Future versions may support alternative data structures, such as hash tables.