mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 19:42:00 +00:00
Fixes memory leak in hash dictionary
Fixes case when keys might not be loaded for complex key hash dictionary
This commit is contained in:
parent
7658665737
commit
89ca08147b
@ -247,7 +247,7 @@ void ComplexKeyHashedDictionary::updateData()
|
||||
saved_block = std::make_shared<DB::Block>(block.cloneEmpty());
|
||||
for (const auto attribute_idx : ext::range(0, keys_size + attributes_size))
|
||||
{
|
||||
const IColumn &update_column = *block.getByPosition(attribute_idx).column.get();
|
||||
const IColumn & update_column = *block.getByPosition(attribute_idx).column.get();
|
||||
MutableColumnPtr saved_column = saved_block->getByPosition(attribute_idx).column->mutate();
|
||||
saved_column->insertRangeFrom(update_column, 0, update_column.size());
|
||||
}
|
||||
@ -272,7 +272,6 @@ void ComplexKeyHashedDictionary::updateData()
|
||||
return block.safeGetByPosition(key_idx).column;
|
||||
});
|
||||
|
||||
const auto &saved_columns = saved_block->mutateColumns();
|
||||
|
||||
std::vector<int> update_indices, saved_indices;
|
||||
for (size_t i = 0; i < saved_block->rows(); ++i)
|
||||
@ -292,6 +291,9 @@ void ComplexKeyHashedDictionary::updateData()
|
||||
u_temp_key_pool.rollback(u_key.size);
|
||||
}
|
||||
}
|
||||
|
||||
auto saved_columns = saved_block->mutateColumns();
|
||||
|
||||
BlockPtr temp_block = std::make_shared<DB::Block>(saved_block->cloneEmpty());
|
||||
for (const auto attribute_idx : ext::range(0, keys_size + attributes_size))
|
||||
{
|
||||
@ -334,6 +336,8 @@ void ComplexKeyHashedDictionary::updateData()
|
||||
saved_block = std::make_shared<DB::Block>(*temp_block);
|
||||
temp_block.reset();
|
||||
}
|
||||
else
|
||||
saved_block->setColumns(std::move(saved_columns));
|
||||
}
|
||||
stream->readSuffix();
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ std::string ExternalQueryBuilder::composeLoadAllQuery() const
|
||||
std::string ExternalQueryBuilder::composeUpdateQuery(const std::string &update_field, std::string &time_point) const
|
||||
{
|
||||
std::string out = composeLoadAllQuery();
|
||||
std::string update_query = " WHERE " + update_field + " > '" + time_point + "'";
|
||||
std::string update_query = " WHERE " + update_field + " >= '" + time_point + "'";
|
||||
out.insert(out.size()-1, update_query);
|
||||
|
||||
return out;
|
||||
|
@ -296,6 +296,8 @@ void HashedDictionary::updateData()
|
||||
saved_column->insertRangeFrom(update_column, 0, update_column.size());
|
||||
}
|
||||
}
|
||||
stream->readSuffix();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -342,16 +344,15 @@ void HashedDictionary::updateData()
|
||||
}
|
||||
else
|
||||
temp_columns[attribute_idx]->insertFrom(*saved_block->safeGetByPosition(attribute_idx).column, i);
|
||||
|
||||
for (size_t i = 0; i < update_id_column.size(); ++i)
|
||||
}
|
||||
for (size_t i = 0; i < update_id_column.size(); ++i)
|
||||
{
|
||||
bool exists = std::any_of(update_indices.begin(), update_indices.end(), [&](size_t x)
|
||||
{
|
||||
bool exists = std::any_of(update_indices.begin(), update_indices.end(), [&](size_t x)
|
||||
{
|
||||
return x == i;
|
||||
});
|
||||
if (!exists)
|
||||
temp_columns[attribute_idx]->insertFrom(*block.safeGetByPosition(attribute_idx).column, i);
|
||||
}
|
||||
return x == i;
|
||||
});
|
||||
if (!exists)
|
||||
temp_columns[attribute_idx]->insertFrom(*block.safeGetByPosition(attribute_idx).column, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -362,6 +363,7 @@ void HashedDictionary::updateData()
|
||||
temp_block.reset();
|
||||
}
|
||||
}
|
||||
stream->readSuffix();
|
||||
}
|
||||
|
||||
if (saved_block)
|
||||
|
@ -72,7 +72,7 @@ void MySQLDictionarySource::setDate()
|
||||
char buffer [80];
|
||||
struct tm * timeinfo;
|
||||
timeinfo = localtime (&hr_time);
|
||||
strftime(buffer, 80, "%Y-%m-%d%%20%H:%M:%S", timeinfo);
|
||||
strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
|
||||
std::string str_time(buffer);
|
||||
date = str_time;
|
||||
}
|
||||
@ -88,9 +88,7 @@ void MySQLDictionarySource::setDate()
|
||||
strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
|
||||
std::string str_time(buffer);
|
||||
date = str_time;
|
||||
std::string tmp = load_all_query;
|
||||
tmp.pop_back();
|
||||
load_all_query_update = tmp + " WHERE " + update_field + " > '" + date + "';";
|
||||
load_all_query_update = query_builder.composeUpdateQuery(update_field, date);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user