MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
Represents an SSTable (Sorted String Table) in the LSM-Tree. 更多...
#include <ob_sstable.h>
Public 成员函数 | |
ObSSTable (uint32_t sst_id, const string &file_name, const ObComparator *comparator, ObLRUCache< uint64_t, shared_ptr< ObBlock > > *block_cache) | |
Constructor for ObSSTable. 更多... | |
void | init () |
Initializes the SSTable instance. 更多... | |
uint32_t | sst_id () const |
shared_ptr< ObSSTable > | get_shared_ptr () |
ObLsmIterator * | new_iterator () |
shared_ptr< ObBlock > | read_block_with_cache (uint32_t block_idx) const |
Reads a block from the SSTable using the block cache. 更多... | |
shared_ptr< ObBlock > | read_block (uint32_t block_idx) const |
Reads a block directly from the SSTable file. 更多... | |
uint32_t | block_count () const |
uint32_t | size () const |
const BlockMeta | block_meta (int i) const |
const ObComparator * | comparator () const |
void | remove () |
string | first_key () const |
string | last_key () const |
Private 属性 | |
uint32_t | sst_id_ |
string | file_name_ |
const ObComparator * | comparator_ = nullptr |
unique_ptr< ObFileReader > | file_reader_ |
vector< BlockMeta > | block_metas_ |
ObLRUCache< uint64_t, shared_ptr< ObBlock > > * | block_cache_ |
Represents an SSTable (Sorted String Table) in the LSM-Tree.
The ObSSTable
class is responsible for managing on-disk sorted string tables (SSTables). It provides methods for initialization, key-value lookups, block reading (with caching support), and creating iterators for traversal. Each SSTable is uniquely identified by an sst_id_
and interacts with the LRU cache for efficient block access.
|
inline |
Constructor for ObSSTable.
Initializes an SSTable with its unique ID, file name, comparator, and block cache.
sst_id | A unique identifier for the SSTable. |
file_name | The name of the file storing the SSTable data. |
comparator | A pointer to the comparator used for key comparison. |
block_cache | A pointer to the LRU block cache for caching block-level data. |
void oceanbase::ObSSTable::init | ( | ) |
Initializes the SSTable instance.
This function is responsible for performing setup tasks required for the SSTable, such as preparing file readers or pre-loading block_metas_.
shared_ptr< ObBlock > oceanbase::ObSSTable::read_block | ( | uint32_t | block_idx | ) | const |
Reads a block directly from the SSTable file.
This function bypasses the block cache and directly reads the requested block from the SSTable file.
block_idx | The index of the block to read. |
shared_ptr< ObBlock > oceanbase::ObSSTable::read_block_with_cache | ( | uint32_t | block_idx | ) | const |
Reads a block from the SSTable using the block cache.
Attempts to read the specified block using the block cache. If the block is not in the cache, it will load the block from the SSTable file and update the cache.
block_idx | The index of the block to read. |