MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / initialize

Method initialize

src/Storages/StorageFile.cpp:2118–2145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2116 }
2117
2118 void initialize()
2119 {
2120 std::unique_ptr<WriteBufferFromFileDescriptor> naked_buffer;
2121 if (use_table_fd)
2122 {
2123 naked_buffer = std::make_unique<WriteBufferFromFileDescriptor>(table_fd, DBMS_DEFAULT_BUFFER_SIZE);
2124 }
2125 else
2126 {
2127 flags |= O_WRONLY | O_APPEND | O_CREAT;
2128 naked_buffer = std::make_unique<WriteBufferFromFile>(path, DBMS_DEFAULT_BUFFER_SIZE, flags);
2129 }
2130
2131 /// In case of formats with prefixes if file is not empty we have already written prefix.
2132 bool do_not_write_prefix = naked_buffer->size();
2133 const auto & settings = getContext()->getSettingsRef();
2134 write_buf = wrapWriteBufferWithCompressionMethod(
2135 std::move(naked_buffer),
2136 compression_method,
2137 static_cast<int>(settings[Setting::output_format_compression_level]),
2138 static_cast<int>(settings[Setting::output_format_compression_zstd_window_log]));
2139
2140 writer = FormatFactory::instance().getOutputFormatParallelIfPossible(format_name,
2141 *write_buf, metadata_snapshot->getSampleBlock(), getContext(), format_settings);
2142
2143 if (do_not_write_prefix)
2144 writer->doNotWritePrefix();
2145 }
2146
2147 String getName() const override { return "StorageFileSink"; }
2148

Callers

nothing calls this directly

Calls 6

doNotWritePrefixMethod · 0.80
getContextFunction · 0.50
sizeMethod · 0.45
getSampleBlockMethod · 0.45

Tested by

no test coverage detected