Skip to content

Commit

Permalink
dbcopy: use a constexpr variable instead of magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Feb 27, 2020
1 parent 459b0c3 commit 0849483
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/src/dird/dbcopy/progress.cc
Expand Up @@ -46,6 +46,8 @@ Progress::Progress(BareosDb* db,
const std::string& table_name,
std::size_t limit_amount_of_rows_)
{
std::cout << "--> request number of rows to be copied" << std::endl;

Amount a;
std::string query{"SELECT count(*) from " + table_name};

Expand Down Expand Up @@ -76,7 +78,7 @@ bool Progress::Increment()
}

state_.amount = state_.amount != 0 ? state_.amount - 1 : 0;
if ((state_.amount % 10000) != 0) { return false; }
if ((state_.amount % number_of_rows_per_increment_) != 0) { return false; }

state_.start = system_clock::now();

Expand Down
1 change: 1 addition & 0 deletions core/src/dird/dbcopy/progress.h
Expand Up @@ -49,6 +49,7 @@ class Progress {
bool Increment();

using Ratio = std::ratio<100, 1>;
static constexpr std::size_t number_of_rows_per_increment_ = 250000;

std::size_t FullAmount() const { return state_.amount; }
std::size_t Rate() const { return state_.ratio; }
Expand Down

0 comments on commit 0849483

Please sign in to comment.