FlatDictionary improve data load performance

This commit is contained in:
Maksim Kita 2022-01-21 15:01:55 +00:00
parent cb7bac2db5
commit 2d712b1d26

View File

@ -291,30 +291,27 @@ void FlatDictionary::blockToAttributes(const Block & block)
DictionaryKeysArenaHolder<DictionaryKeyType::Simple> arena_holder;
DictionaryKeysExtractor<DictionaryKeyType::Simple> keys_extractor({ keys_column }, arena_holder.getComplexKeyArena());
auto keys = keys_extractor.extractAllKeys();
size_t keys_size = keys_extractor.getKeysSize();
HashSet<UInt64> already_processed_keys;
size_t key_offset = 1;
static constexpr size_t key_offset = 1;
for (size_t attribute_index = 0; attribute_index < attributes.size(); ++attribute_index)
{
const IColumn & attribute_column = *block.safeGetByPosition(attribute_index + key_offset).column;
Attribute & attribute = attributes[attribute_index];
for (size_t i = 0; i < keys.size(); ++i)
for (size_t i = 0; i < keys_size; ++i)
{
auto key = keys[i];
if (already_processed_keys.find(key) != nullptr)
auto key = keys_extractor.extractCurrentKey();
if (unlikely(loaded_keys[key]))
continue;
already_processed_keys.insert(key);
setAttributeValue(attribute, key, attribute_column[i]);
++element_count;
keys_extractor.rollbackCurrentKey();
}
already_processed_keys.clear();
keys_extractor.reset();
}
}