| 1 | #pragma once |
| 2 | |
| 3 | #include <Storages/MergeTree/IMergedBlockOutputStream.h> |
| 4 | |
| 5 | namespace DB |
| 6 | { |
| 7 | |
| 8 | /// Writes only those columns that are in `header` |
| 9 | class MergedColumnOnlyOutputStream final : public IMergedBlockOutputStream |
| 10 | { |
| 11 | public: |
| 12 | /// skip_offsets: used when ALTERing columns if we know that array offsets are not altered. |
| 13 | /// Pass empty 'already_written_offset_columns' first time then and pass the same object to subsequent instances of MergedColumnOnlyOutputStream |
| 14 | /// if you want to serialize elements of Nested data structure in different instances of MergedColumnOnlyOutputStream. |
| 15 | MergedColumnOnlyOutputStream( |
| 16 | MergeTreeData & storage_, const Block & , const String & part_path_, bool sync_, |
| 17 | CompressionCodecPtr default_codec_, bool skip_offsets_, |
| 18 | const std::vector<MergeTreeIndexPtr> & indices_to_recalc_, |
| 19 | WrittenOffsetColumns & already_written_offset_columns_, |
| 20 | const MergeTreeIndexGranularity & index_granularity_, |
| 21 | const MergeTreeIndexGranularityInfo * index_granularity_info_ = nullptr); |
| 22 | |
| 23 | Block getHeader() const override { return header; } |
| 24 | void write(const Block & block) override; |
| 25 | void writeSuffix() override; |
| 26 | MergeTreeData::DataPart::Checksums writeSuffixAndGetChecksums(); |
| 27 | |
| 28 | private: |
| 29 | Block header; |
| 30 | |
| 31 | bool sync; |
| 32 | bool skip_offsets; |
| 33 | |
| 34 | /// To correctly write Nested elements column-by-column. |
| 35 | WrittenOffsetColumns & already_written_offset_columns; |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | } |
| 40 | |