| 306 | } |
| 307 | |
| 308 | void writeRemoteConvert( |
| 309 | const DistributedHeader & distributed_header, |
| 310 | RemoteBlockOutputStream & remote, |
| 311 | bool compression_expected, |
| 312 | ReadBufferFromFile & in, |
| 313 | Poco::Logger * log) |
| 314 | { |
| 315 | if (!remote.getHeader()) |
| 316 | { |
| 317 | CheckingCompressedReadBuffer checking_in(in); |
| 318 | remote.writePrepared(checking_in); |
| 319 | return; |
| 320 | } |
| 321 | |
| 322 | /// This is old format, that does not have header for the block in the file header, |
| 323 | /// applying ConvertingBlockInputStream in this case is not a big overhead. |
| 324 | /// |
| 325 | /// Anyway we can get header only from the first block, which contain all rows anyway. |
| 326 | if (!distributed_header.block_header) |
| 327 | { |
| 328 | LOG_TRACE(log, "Processing batch {} with old format (no header)", in.getFileName()); |
| 329 | |
| 330 | writeAndConvert(remote, in); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | if (!blocksHaveEqualStructure(distributed_header.block_header, remote.getHeader())) |
| 335 | { |
| 336 | LOG_WARNING(log, |
| 337 | "Structure does not match (remote: {}, local: {}), implicit conversion will be done", |
| 338 | remote.getHeader().dumpStructure(), distributed_header.block_header.dumpStructure()); |
| 339 | |
| 340 | writeAndConvert(remote, in); |
| 341 | return; |
| 342 | } |
| 343 | |
| 344 | /// If connection does not use compression, we have to uncompress the data. |
| 345 | if (!compression_expected) |
| 346 | { |
| 347 | writeAndConvert(remote, in); |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | /// Otherwise write data as it was already prepared (more efficient path). |
| 352 | CheckingCompressedReadBuffer checking_in(in); |
| 353 | remote.writePrepared(checking_in); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 |
no test coverage detected