13#include "common/sys/rc.h"
14#include "common/lang/string.h"
15#include "common/lang/string_view.h"
16#include "common/lang/memory.h"
17#include "oblsm/memtable/ob_skiplist.h"
18#include "oblsm/util/ob_comparator.h"
19#include "oblsm/util/ob_arena.h"
20#include "oblsm/include/ob_lsm_iterator.h"
33class ObMemTable :
public enable_shared_from_this<ObMemTable>
62 void put(uint64_t seq,
const string_view &key,
const string_view &value);
104 int operator()(
const char *a,
const char *b)
const;
150 void seek(
const string_view &k)
override;
154 bool valid()
const override {
return iter_.valid(); }
155 void next()
override { iter_.next(); }
156 string_view
key()
const override;
157 string_view
value()
const override;
160 shared_ptr<ObMemTable> mem_;
161 ObMemTable::Table::Iterator iter_;
a simple memory allocator.
Definition: ob_arena.h:26
internal key comparator
Definition: ob_comparator.h:49
Abstract class for iterating over key-value pairs in an LSM-Tree.
Definition: ob_lsm_iterator.h:41
An iterator for traversing the contents of an ObMemTable.
Definition: ob_memtable.h:141
void next() override
Moves the iterator to the next key-value pair in the source.
Definition: ob_memtable.h:155
void seek_to_first() override
Positions the iterator at the first key-value pair in the source.
Definition: ob_memtable.h:151
void seek(const string_view &k) override
Positions the iterator at the first entry with a key greater than or equal to the specified key.
Definition: ob_memtable.cpp:65
bool valid() const override
Checks if the iterator is currently positioned at a valid key-value pair.
Definition: ob_memtable.h:154
string_view key() const override
Returns the key of the current entry the iterator is positioned at.
Definition: ob_memtable.cpp:57
void seek_to_last() override
Positions the iterator at the last key-value pair in the source.
Definition: ob_memtable.h:152
string_view value() const override
Returns the value of the current entry the iterator is positioned at.
Definition: ob_memtable.cpp:59
MemTable implementation for LSM-Tree.
Definition: ob_memtable.h:34
Table table_
The underlying data structure used for key-value storage.
Definition: ob_memtable.h:125
shared_ptr< ObMemTable > get_shared_ptr()
Retrieves a shared pointer to the current ObMemTable instance.
Definition: ob_memtable.h:49
ObArena arena_
Memory arena used for memory management in the memtable.
Definition: ob_memtable.h:133
ObLsmIterator * new_iterator()
Creates a new iterator for traversing the contents of the memtable.
Definition: ob_memtable.cpp:55
size_t appro_memory_usage() const
Estimates the memory usage of the memtable.
Definition: ob_memtable.h:72
void put(uint64_t seq, const string_view &key, const string_view &value)
Inserts a key-value pair into the memtable.
Definition: ob_memtable.cpp:19
KeyComparator comparator_
Comparator used for ordering keys in the memtable.
Definition: ob_memtable.h:117
Definition: ob_skiplist.h:48
Compares two keys.
Definition: ob_memtable.h:101