Placed move TTL rules to a vector.

This commit is contained in:
Vladimir Chebotarev 2019-11-28 09:44:26 +03:00
parent ae4b2b4ace
commit 7407f7c39d
5 changed files with 9 additions and 9 deletions

View File

@ -205,9 +205,9 @@ void TTLBlockInputStream::removeValuesWithExpiredColumnTTL(Block & block)
void TTLBlockInputStream::updateMovesTTL(Block & block)
{
std::vector<String> columns_to_remove;
for (const auto & [name, ttl_entry] : storage.move_ttl_entries_by_name)
for (const auto & ttl_entry : storage.move_ttl_entries)
{
auto & new_ttl_info = new_ttl_infos.moves_ttl[name];
auto & new_ttl_info = new_ttl_infos.moves_ttl[ttl_entry.result_column];
if (!block.has(ttl_entry.result_column))
{

View File

@ -637,7 +637,7 @@ void MergeTreeData::setTTLExpressions(const ColumnsDescription::ColumnTTLs & new
{
new_ttl_entry.destination_type = ttl_element.destination_type;
new_ttl_entry.destination_name = ttl_element.destination_name;
move_ttl_entries_by_name.emplace(new_ttl_entry.result_column, new_ttl_entry);
move_ttl_entries.emplace_back(std::move(new_ttl_entry));
}
}
}
@ -3729,9 +3729,9 @@ const MergeTreeData::TTLEntry * MergeTreeData::selectMoveDestination(
/// Prefer TTL rule which went into action last.
time_t max_min_ttl = 0;
for (const auto & [name, ttl_entry] : move_ttl_entries_by_name)
for (const auto & ttl_entry : move_ttl_entries)
{
auto ttl_info_it = ttl_infos.moves_ttl.find(name);
auto ttl_info_it = ttl_infos.moves_ttl.find(ttl_entry.result_column);
if (ttl_info_it != ttl_infos.moves_ttl.end()
&& ttl_info_it->second.min >= minimum_time
&& max_min_ttl <= ttl_info_it->second.min)

View File

@ -737,7 +737,7 @@ public:
TTLEntriesByName column_ttl_entries_by_name;
TTLEntry ttl_table_entry;
TTLEntriesByName move_ttl_entries_by_name;
std::vector<TTLEntry> move_ttl_entries;
String sampling_expr_column_name;
Names columns_required_for_sampling;

View File

@ -226,8 +226,8 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataWriter::writeTempPart(BlockWithPa
size_t expected_size = block.bytes();
DB::MergeTreeDataPart::TTLInfos move_ttl_infos;
for (const auto & [name, ttl_entry] : data.move_ttl_entries_by_name)
updateTTL(ttl_entry, move_ttl_infos, move_ttl_infos.moves_ttl[name], block);
for (const auto & ttl_entry : data.move_ttl_entries)
updateTTL(ttl_entry, move_ttl_infos, move_ttl_infos.moves_ttl[ttl_entry.result_column], block);
DiskSpace::ReservationPtr reservation = data.reserveSpacePreferringMoveDestination(expected_size, move_ttl_infos, time(nullptr));