Skip to content

Commit 824d4df

Browse files
committed
refactor(wal_history): add noexcept specifier to constructors and improve documentation
1 parent 5dfa5b6 commit 824d4df

2 files changed

Lines changed: 54 additions & 8 deletions

File tree

src/limestone/wal_sync/wal_history.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ std::vector<wal_history::record> wal_history::read_all_records(const boost::file
127127

128128

129129

130-
wal_history::wal_history(boost::filesystem::path dir_path)
130+
wal_history::wal_history(boost::filesystem::path dir_path) noexcept
131131
: dir_path_(std::move(dir_path)) {}
132132

133133

134-
boost::filesystem::path wal_history::get_file_path() const {
134+
boost::filesystem::path wal_history::get_file_path() const noexcept {
135135
return dir_path_ / file_name_;
136136
}
137137

src/limestone/wal_sync/wal_history.h

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,69 @@ namespace limestone::internal {
2828

2929
using epoch_id_type = uint64_t;
3030

31+
3132
class wal_history {
3233
public:
34+
/**
35+
* @brief Size of the unique_id field in bytes.
36+
*/
3337
static constexpr std::size_t unique_id_size = 16;
38+
39+
/**
40+
* @brief Structure representing a single WAL history record.
41+
*/
3442
struct record {
35-
epoch_id_type epoch;
36-
std::array<std::uint8_t, unique_id_size> unique_id;
37-
std::time_t timestamp;
43+
epoch_id_type epoch; ///< Epoch value.
44+
std::array<std::uint8_t, unique_id_size> unique_id; ///< 16-byte unique identifier.
45+
std::time_t timestamp; ///< UNIX timestamp (seconds since epoch).
3846
};
3947

40-
explicit wal_history(boost::filesystem::path dir_path);
4148

49+
/**
50+
* @brief Constructs a wal_history object for the specified directory.
51+
* @param dir_path Directory path where the wal_history file is stored.
52+
* @note This constructor does not throw exceptions.
53+
*/
54+
explicit wal_history(boost::filesystem::path dir_path) noexcept;
55+
56+
/**
57+
* @brief Appends a new WAL history record for the given epoch.
58+
* @param epoch The epoch value to append.
59+
* @throws limestone::api::limestone_io_exception I/O error
60+
*/
4261
void append(epoch_id_type epoch);
62+
63+
/**
64+
* @brief Returns a list of all WAL history records.
65+
* @return Vector of WAL history records.
66+
* @throws limestone::api::limestone_io_exception I/O error
67+
*/
4368
[[nodiscard]] std::vector<record> list() const;
69+
70+
/**
71+
* @brief Checks the WAL history file and recovers if necessary.
72+
* @throws limestone::api::limestone_io_exception I/O error
73+
*/
4474
void check_and_recover();
75+
76+
/**
77+
* @brief Checks if the WAL history file exists.
78+
* @return true if the file exists, false otherwise.
79+
* @throws limestone::api::limestone_io_exception I/O error
80+
*/
4581
[[nodiscard]] bool exists() const;
46-
[[nodiscard]] boost::filesystem::path get_file_path() const;
47-
[[nodiscard]] static constexpr const char* file_name() { return file_name_; }
82+
83+
/**
84+
* @brief Returns the file path of the WAL history file.
85+
* @return Path to the WAL history file.
86+
*/
87+
[[nodiscard]] boost::filesystem::path get_file_path() const noexcept;
88+
89+
/**
90+
* @brief Returns the file name of the WAL history file.
91+
* @return File name as a string literal.
92+
*/
93+
[[nodiscard]] static constexpr const char* file_name() noexcept{ return file_name_; }
4894

4995
protected:
5096
// Note: These members are protected (not private) to allow access from test subclasses.

0 commit comments

Comments
 (0)