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

Public 成员函数

 WAL ()
 Default constructor for the Wal class.
 
 ~WAL ()=default
 Destructor for the Wal class. Ensures that the file writer is closed when the Wal object is destroyed.
 
RC open (const std::string &filename)
 Opens the WAL file for writing. This function initializes the file writer and prepares the WAL file for appending data. If the file cannot be opened, an error code is returned. 更多...
 
RC recover (const std::string &wal_file, std::vector< WalRecord > &wal_records)
 Recovers data from a specified WAL file. 更多...
 
RC put (uint64_t seq, std::string_view key, std::string_view val)
 Writes a key-value pair to the WAL. 更多...
 
RC sync ()
 Synchronizes the WAL to disk. Forces any buffered data in the WAL to be written to the underlying storage. 更多...
 
const string & filename () const
 

Private 属性

string filename_
 

成员函数说明

◆ open()

RC oceanbase::WAL::open ( const std::string &  filename)
inline

Opens the WAL file for writing. This function initializes the file writer and prepares the WAL file for appending data. If the file cannot be opened, an error code is returned.

参数
filenameThe name of the WAL file to write logs.
返回
RC::SUCCESS if the file was successfully opened, or an error code if it failed.

◆ put()

RC oceanbase::WAL::put ( uint64_t  seq,
std::string_view  key,
std::string_view  val 
)

Writes a key-value pair to the WAL.

This function serializes the key-value pair and appends it to the WAL file.

参数
seqThe sequence number of the record.
keyThe key to write.
valThe value associated with the key.
返回
RC::SUCCESS if the write operation is successful, or an error code if it fails.

◆ recover()

RC oceanbase::WAL::recover ( const std::string &  wal_file,
std::vector< WalRecord > &  wal_records 
)

Recovers data from a specified WAL file.

This function reads the given WAL file, extracts key-value pairs, and stores them in the provided vector. It also returns the total number of records read from the WAL.

参数
wal_fileThe name of the WAL file to recover from.
wal_recordsA reference to a vector where the WalRecord objects will be stored.
返回
RC::SUCCESS if recovery is successful, or an error code if it fails.

◆ sync()

RC oceanbase::WAL::sync ( )
inline

Synchronizes the WAL to disk. Forces any buffered data in the WAL to be written to the underlying storage.

返回
RC::SUCCESS if the sync operation is successful, or an error code if it fails.

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