| 1203 | } |
| 1204 | |
| 1205 | void MergeTreeDataMutator::finalizeMutatedPart( |
| 1206 | const MergeTreeDataPartPtr & source_part, |
| 1207 | MergeTreeData::MutableDataPartPtr new_data_part, |
| 1208 | const CompressionCodecPtr & codec) |
| 1209 | { |
| 1210 | auto disk = new_data_part->volume->getDisk(); |
| 1211 | // when generating empty partial parts, the directory will not be created before, so we should create it manually. |
| 1212 | String new_part_tmp_rel_path = new_data_part->getFullRelativePath(); |
| 1213 | if (!disk->exists(new_part_tmp_rel_path)) |
| 1214 | disk->createDirectories(new_part_tmp_rel_path); |
| 1215 | |
| 1216 | auto new_part_checksums_ptr = new_data_part->getChecksums(); |
| 1217 | if (new_data_part->uuid != UUIDHelpers::Nil) |
| 1218 | { |
| 1219 | auto out = disk->writeFile(new_data_part->getFullRelativePath() + IMergeTreeDataPart::UUID_FILE_NAME, {.buffer_size = 4096}); |
| 1220 | HashingWriteBuffer out_hashing(*out); |
| 1221 | writeUUIDText(new_data_part->uuid, out_hashing); |
| 1222 | new_part_checksums_ptr->files[IMergeTreeDataPart::UUID_FILE_NAME].file_size = out_hashing.count(); |
| 1223 | new_part_checksums_ptr->files[IMergeTreeDataPart::UUID_FILE_NAME].file_hash = out_hashing.getHash(); |
| 1224 | } |
| 1225 | |
| 1226 | { |
| 1227 | /// Write file with checksums. |
| 1228 | auto out_checksums = disk->writeFile(fs::path(new_data_part->getFullRelativePath()) / "checksums.txt", {.buffer_size = 4096}); |
| 1229 | new_part_checksums_ptr->versions = new_data_part->versions; |
| 1230 | new_part_checksums_ptr->write(*out_checksums); |
| 1231 | } /// close fd |
| 1232 | |
| 1233 | { |
| 1234 | auto out = disk->writeFile(new_data_part->getFullRelativePath() + IMergeTreeDataPart::DEFAULT_COMPRESSION_CODEC_FILE_NAME, {.buffer_size = 4096}); |
| 1235 | DB::writeText(queryToString(codec->getFullCodecDesc()), *out); |
| 1236 | } |
| 1237 | |
| 1238 | { |
| 1239 | /// Write a file with a description of columns. |
| 1240 | auto out_columns = disk->writeFile(fs::path(new_data_part->getFullRelativePath()) / "columns.txt", {.buffer_size = 4096}); |
| 1241 | new_data_part->getColumns().writeText(*out_columns); |
| 1242 | } /// close fd |
| 1243 | |
| 1244 | new_data_part->rows_count = source_part->rows_count; |
| 1245 | new_data_part->index_granularity = source_part->index_granularity; |
| 1246 | new_data_part->index = source_part->getIndex(); |
| 1247 | new_data_part->minmax_idx = source_part->minmax_idx; |
| 1248 | new_data_part->modification_time = time(nullptr); |
| 1249 | // new_data_part->loadProjections(false, false); |
| 1250 | new_data_part->setBytesOnDisk( |
| 1251 | MergeTreeData::DataPart::calculateTotalSizeOnDisk(new_data_part->volume->getDisk(), new_data_part->getFullRelativePath())); |
| 1252 | new_data_part->default_codec = codec; |
| 1253 | // TODO: |
| 1254 | // new_data_part->mutation_commit_time = manipulation_entry. |
| 1255 | // new_data_part->calculateColumnsSizesOnDisk(); |
| 1256 | // new_data_part->storage.lockSharedData(*new_data_part); |
| 1257 | } |
| 1258 | |
| 1259 | bool MergeTreeDataMutator::checkOperationIsNotCanceled(const ManipulationListEntry & manipulation_entry) const |
| 1260 | { |
nothing calls this directly
no test coverage detected