Skip to content

Commit

Permalink
Refactor code to address clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
umegane committed Feb 18, 2025
1 parent 73ea9e7 commit 41550b6
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/limestone/compaction_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
namespace limestone::internal {

class compaction_options {
public:
public:
// Constructor: Pre-compaction phase where to_dir is not provided.
// File set is provided and GC is disabled.
// In this constructor, "/not_exists_dir" is set for to_dir to indicate an error if used.
compaction_options(
const boost::filesystem::path& from,

Check warning on line 34 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
int workers,
std::set<std::string> file_names
const std::set<std::string>& file_names

Check warning on line 36 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
)
: from_dir_(from),
to_dir_("/not_exists_dir"),
Expand All @@ -52,7 +52,6 @@
: from_dir_(from),
to_dir_(to),
num_worker_(workers),
file_names_(),
has_file_set_(false),
gc_snapshot_(std::nullopt)
{}
Expand All @@ -62,7 +61,7 @@
const boost::filesystem::path& from,

Check warning on line 61 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
const boost::filesystem::path& to,

Check warning on line 62 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
int workers,
std::set<std::string> file_names
const std::set<std::string>& file_names

Check warning on line 64 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
)
: from_dir_(from),
to_dir_(to),
Expand All @@ -78,7 +77,7 @@
const boost::filesystem::path& from,

Check warning on line 77 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
const boost::filesystem::path& to,

Check warning on line 78 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
int workers,
std::set<std::string> file_names,
const std::set<std::string>& file_names,

Check warning on line 80 in src/limestone/compaction_options.h

View workflow job for this annotation

GitHub Actions / Clang-Tidy

modernize-pass-by-value

pass by value and use std::move
blob_file_gc_snapshot& gc_snapshot
)
: from_dir_(from),
Expand All @@ -89,35 +88,35 @@
gc_snapshot_(std::ref(gc_snapshot))
{}

// Getter for from_dir
const boost::filesystem::path& get_from_dir() const { return from_dir_; }
// Getter for from_dir.
[[nodiscard]] const boost::filesystem::path& get_from_dir() const { return from_dir_; }

// Getter for to_dir.
const boost::filesystem::path& get_to_dir() const { return to_dir_; }
[[nodiscard]] const boost::filesystem::path& get_to_dir() const { return to_dir_; }

// Getter for num_worker.
int get_num_worker() const { return num_worker_; }
[[nodiscard]] int get_num_worker() const { return num_worker_; }

// Getter for file_names.
const std::set<std::string>& get_file_names() const { return file_names_; }
[[nodiscard]] const std::set<std::string>& get_file_names() const { return file_names_; }

// Returns true if a file set is configured.
bool has_file_set() const { return has_file_set_; }
[[nodiscard]] bool has_file_set() const { return has_file_set_; }

// Check if GC is enabled.
bool is_gc_enabled() const { return gc_snapshot_.has_value(); }
[[nodiscard]] bool is_gc_enabled() const { return gc_snapshot_.has_value(); }

// Getter for gc_snapshot.
// It is caller's responsibility to ensure GC is enabled before calling.
blob_file_gc_snapshot& get_gc_snapshot() const { return gc_snapshot_.value().get(); }
[[nodiscard]] blob_file_gc_snapshot& get_gc_snapshot() const { return gc_snapshot_.value().get(); }

private:
private:
// Basic compaction settings.
boost::filesystem::path from_dir_;
boost::filesystem::path to_dir_;
int num_worker_;

// File set for compaction
// File set for compaction.
std::set<std::string> file_names_;
bool has_file_set_;

Expand Down

0 comments on commit 41550b6

Please sign in to comment.