From a06f2fed9a589c43247f6bd77428c2adf8b546a8 Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Wed, 19 May 2021 19:08:17 +0300 Subject: [PATCH] serializations: fix mutations --- src/DataTypes/Serializations/SerializationInfo.cpp | 5 ----- src/Storages/MergeTree/IMergeTreeDataPart.cpp | 2 +- src/Storages/MergeTree/IMergeTreeDataPart.h | 2 +- src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp | 1 + src/Storages/MergeTree/MergeTreeReaderCompact.cpp | 7 ++++--- src/Storages/MergeTree/checkDataPart.cpp | 4 +++- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/DataTypes/Serializations/SerializationInfo.cpp b/src/DataTypes/Serializations/SerializationInfo.cpp index 01f5909631b..86e8fb93fed 100644 --- a/src/DataTypes/Serializations/SerializationInfo.cpp +++ b/src/DataTypes/Serializations/SerializationInfo.cpp @@ -66,11 +66,6 @@ SerializationInfoPtr SerializationInfoBuilder::build() SerializationInfoPtr SerializationInfoBuilder::buildFrom(const SerializationInfo & other) { - if (info->number_of_rows && info->number_of_rows != other.number_of_rows) - throw Exception(ErrorCodes::LOGICAL_ERROR, - "Cannot update SerializationInfo with {} rows by SerializationInfo with {} rows", - info->number_of_rows, other.number_of_rows); - for (auto & [name, column_info] : other.columns) { auto it = info->columns.find(name); diff --git a/src/Storages/MergeTree/IMergeTreeDataPart.cpp b/src/Storages/MergeTree/IMergeTreeDataPart.cpp index 6a12d35aa10..e0877ff9574 100644 --- a/src/Storages/MergeTree/IMergeTreeDataPart.cpp +++ b/src/Storages/MergeTree/IMergeTreeDataPart.cpp @@ -1009,7 +1009,7 @@ void IMergeTreeDataPart::loadUUID() } } -void IMergeTreeDataPart::loadSerializationInfo() +void IMergeTreeDataPart::loadSerializationInfo() const { String path = getFullRelativePath() + SERIALIZATION_FILE_NAME; if (volume->getDisk()->exists(path)) diff --git a/src/Storages/MergeTree/IMergeTreeDataPart.h b/src/Storages/MergeTree/IMergeTreeDataPart.h index 4228b62d3c4..567e931a3da 100644 --- a/src/Storages/MergeTree/IMergeTreeDataPart.h +++ b/src/Storages/MergeTree/IMergeTreeDataPart.h @@ -462,7 +462,7 @@ private: /// Loads ttl infos in json format from file ttl.txt. If file doesn't exists assigns ttl infos with all zeros void loadTTLInfos(); - void loadSerializationInfo(); + void loadSerializationInfo() const; void loadPartitionAndMinMaxIndex(); diff --git a/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp b/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp index 23edb3916ea..01ab592ada2 100644 --- a/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp +++ b/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp @@ -1253,6 +1253,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor new_data_part->uuid = future_part.uuid; new_data_part->is_temp = true; new_data_part->ttl_infos = source_part->ttl_infos; + new_data_part->serialization_info = source_part->serialization_info; /// It shouldn't be changed by mutation. new_data_part->index_granularity_info = source_part->index_granularity_info; diff --git a/src/Storages/MergeTree/MergeTreeReaderCompact.cpp b/src/Storages/MergeTree/MergeTreeReaderCompact.cpp index 8c244323fcd..f5ebee6b2e4 100644 --- a/src/Storages/MergeTree/MergeTreeReaderCompact.cpp +++ b/src/Storages/MergeTree/MergeTreeReaderCompact.cpp @@ -155,8 +155,9 @@ size_t MergeTreeReaderCompact::readRows(size_t from_mark, bool continue_reading, if (!column_positions[i]) continue; + auto column_from_part = getColumnFromPart(*column_it); if (res_columns[i] == nullptr) - res_columns[i] = getColumnFromPart(*column_it).type->createColumn(*serializations[column_it->name]); + res_columns[i] = column_from_part.type->createColumn(*serializations.at(column_from_part.name)); } while (read_rows < max_rows_to_read) @@ -234,7 +235,7 @@ void MergeTreeReaderCompact::readData( auto name_in_storage = name_and_type.getNameInStorage(); auto type_in_storage = name_and_type.getTypeInStorage(); - const auto & serialization = serializations[name_in_storage]; + const auto & serialization = serializations.at(name_in_storage); ColumnPtr temp_column = type_in_storage->createColumn(*serialization); serialization->deserializeBinaryBulkStatePrefix(deserialize_settings, state); @@ -243,7 +244,7 @@ void MergeTreeReaderCompact::readData( } else { - const auto & serialization = serializations[name]; + const auto & serialization = serializations.at(name); serialization->deserializeBinaryBulkStatePrefix(deserialize_settings, state); serialization->deserializeBinaryBulkWithMultipleStreams(column, rows_to_read, deserialize_settings, state, nullptr); } diff --git a/src/Storages/MergeTree/checkDataPart.cpp b/src/Storages/MergeTree/checkDataPart.cpp index 158bc9600b9..ba59e4e419a 100644 --- a/src/Storages/MergeTree/checkDataPart.cpp +++ b/src/Storages/MergeTree/checkDataPart.cpp @@ -100,9 +100,11 @@ IMergeTreeDataPart::Checksums checkDataPart( }; auto serialization_info = std::make_shared(); + auto serialization_path = path + IMergeTreeDataPart::SERIALIZATION_FILE_NAME; + if (disk->exists(serialization_path)) { - auto serialization_file = disk->readFile(path + IMergeTreeDataPart::SERIALIZATION_FILE_NAME); + auto serialization_file = disk->readFile(serialization_path); serialization_info->readText(*serialization_file); }