提交 89328b49 编写于 作者: A Alexey Milovidov

MergeSelector: development [#METR-21841].

上级 bee00bfc
......@@ -41,6 +41,7 @@ struct Estimator
void selectWithinPartition(
const LevelMergeSelector::PartsInPartition & parts,
const size_t max_total_size_to_merge,
const time_t current_max_part_age,
Estimator & estimator,
const LevelMergeSelector::Settings & settings)
{
......@@ -50,9 +51,9 @@ void selectWithinPartition(
double actual_base = settings.min_parts_to_merge;
if (parts.back().age > settings.lower_base_after)
if (current_max_part_age > settings.lower_base_after)
{
actual_base -= log2(parts.back().age - settings.lower_base_after);
actual_base -= log2(current_max_part_age - settings.lower_base_after);
if (actual_base < 2)
actual_base = 2;
}
......@@ -85,6 +86,9 @@ void selectWithinPartition(
prev_level = part.level;
}
if (!has_range_of_same_level && actual_base > 2)
return;
for (size_t level = 0; level <= max_level; ++level)
{
bool in_range = false;
......@@ -141,10 +145,16 @@ LevelMergeSelector::PartsInPartition LevelMergeSelector::select(
const Partitions & partitions,
const size_t max_total_size_to_merge)
{
time_t max_age = 0;
for (const auto & partition : partitions)
for (const auto & part : partition)
if (part.age > max_age)
max_age = part.age;
Estimator estimator;
for (const auto & partition : partitions)
selectWithinPartition(partition, max_total_size_to_merge, estimator, settings);
selectWithinPartition(partition, max_total_size_to_merge, max_age, estimator, settings);
return estimator.getBest();
}
......
......@@ -74,6 +74,7 @@ struct Estimator
void selectWithinPartition(
const SimpleMergeSelector::PartsInPartition & parts,
const size_t max_total_size_to_merge,
const time_t current_max_part_age,
Estimator & estimator,
const SimpleMergeSelector::Settings & settings)
{
......@@ -82,9 +83,9 @@ void selectWithinPartition(
double actual_base = settings.base;
if (parts.back().age > settings.lower_base_after)
if (current_max_part_age > settings.lower_base_after)
{
actual_base -= log2(parts.back().age - settings.lower_base_after);
actual_base -= log2(current_max_part_age - settings.lower_base_after);
if (actual_base < 1)
actual_base = 1;
}
......@@ -148,10 +149,16 @@ SimpleMergeSelector::PartsInPartition SimpleMergeSelector::select(
const Partitions & partitions,
const size_t max_total_size_to_merge)
{
time_t max_age = 0;
for (const auto & partition : partitions)
for (const auto & part : partition)
if (part.age > max_age)
max_age = part.age;
Estimator estimator;
for (const auto & partition : partitions)
selectWithinPartition(partition, max_total_size_to_merge, estimator, settings);
selectWithinPartition(partition, max_total_size_to_merge, max_age, estimator, settings);
return estimator.getBest();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册