13#include "oblsm/include/ob_lsm.h"
15#include "common/lang/mutex.h"
16#include "common/lang/atomic.h"
17#include "common/lang/memory.h"
18#include "common/lang/condition_variable.h"
19#include "common/lang/utility.h"
20#include "common/thread/thread_pool_executor.h"
21#include "oblsm/include/ob_lsm_transaction.h"
22#include "oblsm/memtable/ob_memtable.h"
23#include "oblsm/table/ob_sstable.h"
24#include "oblsm/util/ob_lru_cache.h"
25#include "oblsm/compaction/ob_compaction.h"
26#include "oblsm/ob_manifest.h"
27#include "oblsm/wal/ob_lsm_wal.h"
35 uint64_t new_memtable_id;
44 if (!options_.force_sync_new_log) {
51 RC
put(
const string_view &key,
const string_view &value)
override;
53 RC
get(
const string_view &key,
string *value)
override;
55 RC
remove(
const string_view &key)
override;
61 SSTablesPtr get_sstables() {
return sstables_; }
64 RC batch_put(
const std::vector<pair<string, string>> &kvs)
override;
70 RC recover_from_wal();
71 RC recover_from_manifest_records(
const std::vector<ObManifestCompaction> &records);
73 RC load_manifest_sstable(
const std::vector<std::vector<uint64_t>> &sstables);
74 RC write_manifest_snapshot();
164 std::shared_ptr<WAL> wal_;
165 std::vector<std::shared_ptr<WAL>> frozen_wals_;
166 shared_ptr<ObMemTable> mem_table_;
167 vector<shared_ptr<ObMemTable>> imem_tables_;
168 SSTablesPtr sstables_;
171 atomic<uint64_t> seq_{0};
172 atomic<uint64_t> sstable_id_{0};
173 atomic<uint64_t> memtable_id_{0};
174 condition_variable cv_;
178 atomic<bool> compacting_ =
false;
179 std::unique_ptr<ObLRUCache<uint64_t, shared_ptr<ObBlock>>> block_cache_;
Definition: thread_pool_executor.h:44
int shutdown()
关闭线程池
Definition: thread_pool_executor.cpp:73
int await_termination()
等待线程池处理完所有任务并退出
Definition: thread_pool_executor.cpp:104
Represents a compaction task in the LSM-Tree.
Definition: ob_compaction.h:28
comparator with lexicographical order
Definition: ob_comparator.h:38
internal key comparator
Definition: ob_comparator.h:49
Definition: ob_lsm_impl.h:39
ObLsmIterator * new_iterator(ObLsmReadOptions options) override
Creates a new iterator for traversing the LSM-Tree database.
Definition: ob_lsm_impl.cpp:333
RC try_freeze_memtable()
Attempts to freeze the current active MemTable.
Definition: ob_lsm_impl.cpp:155
void build_sstable(shared_ptr< ObMemTable > imem)
Builds an SSTable from the given MemTable.
Definition: ob_lsm_impl.cpp:280
RC put(const string_view &key, const string_view &value) override
Inserts or updates a key-value entry in the LSM-Tree.
Definition: ob_lsm_impl.cpp:103
RC get(const string_view &key, string *value) override
Retrieves the value associated with a specified key.
Definition: ob_lsm_impl.cpp:315
vector< shared_ptr< ObSSTable > > do_compaction(ObCompaction *compaction)
Performs compaction on the SSTables selected by the compaction strategy.
Definition: ob_lsm_impl.cpp:278
void dump_sstables() override
Dumps all SSTables for debugging purposes.
Definition: ob_lsm_impl.cpp:362
string get_wal_path(uint64_t memtable_id)
Retrieves the file path for a given Memtable id.
Definition: ob_lsm_impl.cpp:310
void try_major_compaction()
Initiates a major compaction process.
Definition: ob_lsm_impl.cpp:213
void background_compaction(std::shared_ptr< ObLsmBgCompactCtx > ctx)
Handles background compaction tasks.
Definition: ob_lsm_impl.cpp:183
string get_sstable_path(uint64_t sstable_id)
Retrieves the file path for a given SSTable.
Definition: ob_lsm_impl.cpp:305
RC remove(const string_view &key) override
Delete a key-value entry in the LSM-Tree.
Definition: ob_lsm_impl.cpp:153
Abstract class for iterating over key-value pairs in an LSM-Tree.
Definition: ob_lsm_iterator.h:41
A class representing a transaction in oblsm.
Definition: ob_lsm_transaction.h:36
ObLsm is a key-value storage engine for educational purpose. ObLsm learned a lot about design from le...
Definition: ob_lsm.h:29
Represents a snapshot of the manifest.
Definition: ob_manifest.h:202
A class that manages the manifest file, including reading and writing records and snapshots.
Definition: ob_manifest.h:271
Definition: ob_lsm_impl.h:32
Configuration options for the LSM-Tree implementation.
Definition: ob_lsm_options.h:22
Definition: ob_lsm_options.h:48