2019-01-25 11:03:02 +00:00
|
|
|
#include "StopConditionsSet.h"
|
|
|
|
#include <Common/Exception.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int LOGICAL_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopConditionsSet::loadFromConfig(const ConfigurationPtr & stop_conditions_view)
|
|
|
|
{
|
2019-01-28 16:20:29 +00:00
|
|
|
Strings keys;
|
2019-01-25 11:03:02 +00:00
|
|
|
stop_conditions_view->keys(keys);
|
|
|
|
|
2019-01-28 16:20:29 +00:00
|
|
|
for (const std::string & key : keys)
|
2019-01-25 11:03:02 +00:00
|
|
|
{
|
|
|
|
if (key == "total_time_ms")
|
|
|
|
total_time_ms.value = stop_conditions_view->getUInt64(key);
|
|
|
|
else if (key == "rows_read")
|
|
|
|
rows_read.value = stop_conditions_view->getUInt64(key);
|
|
|
|
else if (key == "bytes_read_uncompressed")
|
|
|
|
bytes_read_uncompressed.value = stop_conditions_view->getUInt64(key);
|
|
|
|
else if (key == "iterations")
|
|
|
|
iterations.value = stop_conditions_view->getUInt64(key);
|
|
|
|
else if (key == "min_time_not_changing_for_ms")
|
|
|
|
min_time_not_changing_for_ms.value = stop_conditions_view->getUInt64(key);
|
|
|
|
else if (key == "max_speed_not_changing_for_ms")
|
|
|
|
max_speed_not_changing_for_ms.value = stop_conditions_view->getUInt64(key);
|
|
|
|
else
|
2019-09-13 16:24:59 +00:00
|
|
|
throw Exception("Met unknown stop condition: " + key, ErrorCodes::LOGICAL_ERROR);
|
2019-09-13 16:18:26 +00:00
|
|
|
|
|
|
|
++initialized_count;
|
2019-01-25 11:03:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopConditionsSet::reset()
|
|
|
|
{
|
|
|
|
total_time_ms.fulfilled = false;
|
|
|
|
rows_read.fulfilled = false;
|
|
|
|
bytes_read_uncompressed.fulfilled = false;
|
|
|
|
iterations.fulfilled = false;
|
|
|
|
min_time_not_changing_for_ms.fulfilled = false;
|
|
|
|
max_speed_not_changing_for_ms.fulfilled = false;
|
|
|
|
|
|
|
|
fulfilled_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopConditionsSet::report(UInt64 value, StopConditionsSet::StopCondition & condition)
|
|
|
|
{
|
|
|
|
if (condition.value && !condition.fulfilled && value >= condition.value)
|
|
|
|
{
|
|
|
|
condition.fulfilled = true;
|
|
|
|
++fulfilled_count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|