MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
Public 成员函数 | Private 属性 | 所有成员列表
oceanbase::ObSSTable类 参考

Represents an SSTable (Sorted String Table) in the LSM-Tree. 更多...

#include <ob_sstable.h>

类 oceanbase::ObSSTable 继承关系图:

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< ObSSTableget_shared_ptr ()
 
ObLsmIteratornew_iterator ()
 
shared_ptr< ObBlockread_block_with_cache (uint32_t block_idx) const
 Reads a block from the SSTable using the block cache. 更多...
 
shared_ptr< ObBlockread_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 ObComparatorcomparator () const
 
void remove ()
 
string first_key () const
 
string last_key () const
 

Private 属性

uint32_t sst_id_
 
string file_name_
 
const ObComparatorcomparator_ = nullptr
 
unique_ptr< ObFileReaderfile_reader_
 
vector< BlockMetablock_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.

构造及析构函数说明

◆ ObSSTable()

oceanbase::ObSSTable::ObSSTable ( uint32_t  sst_id,
const string &  file_name,
const ObComparator comparator,
ObLRUCache< uint64_t, shared_ptr< ObBlock > > *  block_cache 
)
inline

Constructor for ObSSTable.

Initializes an SSTable with its unique ID, file name, comparator, and block cache.

参数
sst_idA unique identifier for the SSTable.
file_nameThe name of the file storing the SSTable data.
comparatorA pointer to the comparator used for key comparison.
block_cacheA pointer to the LRU block cache for caching block-level data.

成员函数说明

◆ init()

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_.

警告
This function must be called before performing any operations on the SSTable.

◆ read_block()

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_idxThe index of the block to read.
返回
shared_ptr<ObBlock> A shared pointer to the requested block.

◆ read_block_with_cache()

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_idxThe index of the block to read.
返回
shared_ptr<ObBlock> A shared pointer to the requested block.

该类的文档由以下文件生成: