| 1143 | } |
| 1144 | |
| 1145 | void MergeTreeDataMutator::mutateSomePartColumns( |
| 1146 | const MergeTreeDataPartPtr & source_part, |
| 1147 | const StorageMetadataPtr & metadata_snapshot, |
| 1148 | const std::set<MergeTreeIndexPtr> & indices_to_recalc, |
| 1149 | const std::set<MergeTreeProjectionPtr> & projections_to_recalc, |
| 1150 | const Block & mutation_header, |
| 1151 | MergeTreeData::MutableDataPartPtr new_data_part, |
| 1152 | BlockInputStreamPtr mutating_stream, |
| 1153 | time_t time_of_mutation, |
| 1154 | const CompressionCodecPtr & compression_codec, |
| 1155 | ManipulationListEntry & manipulation_entry, |
| 1156 | bool need_sync, |
| 1157 | const ReservationPtr & space_reservation, |
| 1158 | TableLockHolder & holder, |
| 1159 | ContextPtr context) |
| 1160 | { |
| 1161 | if (mutating_stream == nullptr) |
| 1162 | throw Exception("Cannot mutate part columns with uninitialized mutations stream. It's a bug", ErrorCodes::LOGICAL_ERROR); |
| 1163 | |
| 1164 | if (new_data_part->versions->enable_compact_map_data) |
| 1165 | throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot mutate part {} to compact part. It's a bug.", source_part->name); |
| 1166 | |
| 1167 | IMergedBlockOutputStream::WrittenOffsetColumns unused_written_offsets; |
| 1168 | MergedColumnOnlyOutputStream out( |
| 1169 | new_data_part, |
| 1170 | metadata_snapshot, |
| 1171 | mutation_header, |
| 1172 | compression_codec, |
| 1173 | std::vector<MergeTreeIndexPtr>(indices_to_recalc.begin(), indices_to_recalc.end()), |
| 1174 | nullptr, |
| 1175 | source_part->index_granularity, |
| 1176 | &source_part->index_granularity_info |
| 1177 | ); |
| 1178 | |
| 1179 | mutating_stream->readPrefix(); |
| 1180 | out.writePrefix(); |
| 1181 | |
| 1182 | std::vector<MergeTreeProjectionPtr> projections_to_build(projections_to_recalc.begin(), projections_to_recalc.end()); |
| 1183 | auto row_exists_count = writeWithProjections( |
| 1184 | new_data_part, |
| 1185 | metadata_snapshot, |
| 1186 | projections_to_build, |
| 1187 | mutating_stream, |
| 1188 | out, |
| 1189 | time_of_mutation, |
| 1190 | manipulation_entry, |
| 1191 | space_reservation, |
| 1192 | holder, |
| 1193 | context); |
| 1194 | |
| 1195 | mutating_stream->readSuffix(); |
| 1196 | |
| 1197 | auto changed_checksums = out.writeSuffixAndGetChecksums(new_data_part, *(new_data_part->getChecksums()), need_sync); |
| 1198 | new_data_part->checksums_ptr->add(std::move(changed_checksums)); |
| 1199 | |
| 1200 | /// New part's row_exists_count should be updated if it's DELETE mutation, otherwise it use source part's value. |
| 1201 | if (row_exists_count.has_value()) |
| 1202 | new_data_part->row_exists_count = row_exists_count; |
nothing calls this directly
no test coverage detected