MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
|
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_ |
|
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.
filename | The name of the WAL file to write logs. |
RC::SUCCESS
if the file was successfully opened, or an error code if it failed. RC oceanbase::WAL::put | ( | uint64_t | seq, |
std::string_view | key, | ||
std::string_view | val | ||
) |
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_file | The name of the WAL file to recover from. |
wal_records | A reference to a vector where the WalRecord objects will be stored. |
RC::SUCCESS
if recovery is successful, or an error code if it fails.
|
inline |