MCPcopy Create free account
hub / github.com/ByConity/ByConity / flushToDisk

Method flushToDisk

src/Storages/MergeTree/MergeTreeDataPartInMemory.cpp:97–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97void 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
126void MergeTreeDataPartInMemory::makeCloneInDetached(const String & prefix, const StorageMetadataPtr & metadata_snapshot) const
127{

Callers 2

Calls 15

quoteStringFunction · 0.85
fullPathFunction · 0.85
choosePartTypeOnDiskMethod · 0.80
createPartMethod · 0.80
ExceptionClass · 0.50
getDiskMethod · 0.45
bytesMethod · 0.45
setColumnsMethod · 0.45
existsMethod · 0.45
createDirectoriesMethod · 0.45

Tested by

no test coverage detected