| 95 | } |
| 96 | |
| 97 | void MergeTreeDataPartInMemory::flushToDisk(const String & base_path, const String & new_relative_path, const StorageMetadataPtr & metadata_snapshot) const |
| 98 | { |
| 99 | const auto & disk = volume->getDisk(); |
| 100 | String destination_path = base_path + new_relative_path; |
| 101 | |
| 102 | auto new_type = storage.choosePartTypeOnDisk(block.bytes(), rows_count); |
| 103 | auto new_data_part = storage.createPart(name, new_type, info, volume, new_relative_path); |
| 104 | |
| 105 | new_data_part->uuid = uuid; |
| 106 | new_data_part->setColumns(getColumns()); |
| 107 | new_data_part->partition.value = partition.value; |
| 108 | new_data_part->minmax_idx = minmax_idx; |
| 109 | |
| 110 | if (disk->exists(destination_path)) |
| 111 | { |
| 112 | throw Exception("Could not flush part " + quoteString(getFullPath()) |
| 113 | + ". Part in " + fullPath(disk, destination_path) + " already exists", ErrorCodes::DIRECTORY_ALREADY_EXISTS); |
| 114 | } |
| 115 | |
| 116 | disk->createDirectories(destination_path); |
| 117 | |
| 118 | auto compression_codec = storage.getContext()->chooseCompressionCodec(0, 0); |
| 119 | auto indices = MergeTreeIndexFactory::instance().getMany(metadata_snapshot->getSecondaryIndices()); |
| 120 | MergedBlockOutputStream out(new_data_part, metadata_snapshot, *columns_ptr, indices, compression_codec); |
| 121 | out.writePrefix(); |
| 122 | out.write(block); |
| 123 | out.writeSuffixAndFinalizePart(new_data_part); |
| 124 | } |
| 125 | |
| 126 | void MergeTreeDataPartInMemory::makeCloneInDetached(const String & prefix, const StorageMetadataPtr & metadata_snapshot) const |
| 127 | { |
no test coverage detected