2019-10-21 15:33:59 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-10-16 18:27:53 +00:00
|
|
|
#include <IO/WriteBufferFromFile.h>
|
2019-10-19 16:49:36 +00:00
|
|
|
#include <IO/WriteBufferFromFileBase.h>
|
2019-10-16 18:27:53 +00:00
|
|
|
#include <Compression/CompressedWriteBuffer.h>
|
|
|
|
#include <IO/HashingWriteBuffer.h>
|
|
|
|
#include <Storages/MergeTree/MergeTreeData.h>
|
2019-11-05 11:53:22 +00:00
|
|
|
#include <Storages/MergeTree/IMergeTreeDataPart.h>
|
2020-02-27 16:47:40 +00:00
|
|
|
#include <Disks/IDisk.h>
|
2019-10-16 18:27:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-12-10 08:57:52 +00:00
|
|
|
Block getBlockAndPermute(const Block & block, const Names & names, const IColumn::Permutation * permutation);
|
2020-02-03 12:08:40 +00:00
|
|
|
|
2020-12-14 14:27:39 +00:00
|
|
|
Block permuteBlockIfNeeded(const Block & block, const IColumn::Permutation * permutation);
|
|
|
|
|
2020-02-03 12:08:40 +00:00
|
|
|
/// Writes data part to disk in different formats.
|
|
|
|
/// Calculates and serializes primary and skip indices if needed.
|
2019-12-27 21:17:53 +00:00
|
|
|
class IMergeTreeDataPartWriter : private boost::noncopyable
|
2019-10-16 18:27:53 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-04-14 19:47:19 +00:00
|
|
|
IMergeTreeDataPartWriter(
|
2022-10-22 22:51:59 +00:00
|
|
|
const MergeTreeMutableDataPartPtr & data_part_,
|
2020-04-14 19:47:19 +00:00
|
|
|
const NamesAndTypesList & columns_list_,
|
2020-06-26 11:30:23 +00:00
|
|
|
const StorageMetadataPtr & metadata_snapshot_,
|
2020-12-10 09:22:43 +00:00
|
|
|
const MergeTreeWriterSettings & settings_,
|
|
|
|
const MergeTreeIndexGranularity & index_granularity_ = {});
|
2019-10-19 16:49:36 +00:00
|
|
|
|
2019-12-18 15:54:45 +00:00
|
|
|
virtual ~IMergeTreeDataPartWriter();
|
|
|
|
|
2020-12-10 08:57:52 +00:00
|
|
|
virtual void write(const Block & block, const IColumn::Permutation * permutation) = 0;
|
2019-10-21 17:23:06 +00:00
|
|
|
|
2023-06-22 15:17:13 +00:00
|
|
|
virtual void fillChecksums(IMergeTreeDataPart::Checksums & checksums, NameSet & checksums_to_remove) = 0;
|
2022-02-01 10:36:51 +00:00
|
|
|
|
|
|
|
virtual void finish(bool sync) = 0;
|
2019-10-21 15:33:59 +00:00
|
|
|
|
2020-04-14 01:27:27 +00:00
|
|
|
Columns releaseIndexColumns();
|
|
|
|
const MergeTreeIndexGranularity & getIndexGranularity() const { return index_granularity; }
|
2019-12-19 14:05:26 +00:00
|
|
|
|
2019-10-16 18:27:53 +00:00
|
|
|
protected:
|
2020-12-10 08:57:52 +00:00
|
|
|
|
2022-10-22 22:51:59 +00:00
|
|
|
const MergeTreeMutableDataPartPtr data_part;
|
2019-10-20 23:36:27 +00:00
|
|
|
const MergeTreeData & storage;
|
2020-12-09 18:10:09 +00:00
|
|
|
const StorageMetadataPtr metadata_snapshot;
|
|
|
|
const NamesAndTypesList columns_list;
|
|
|
|
const MergeTreeWriterSettings settings;
|
2020-12-10 09:22:43 +00:00
|
|
|
MergeTreeIndexGranularity index_granularity;
|
2020-12-09 18:10:09 +00:00
|
|
|
const bool with_final_mark;
|
2019-11-05 11:53:22 +00:00
|
|
|
|
|
|
|
MutableColumns index_columns;
|
2019-10-16 18:27:53 +00:00
|
|
|
};
|
|
|
|
|
2019-10-19 16:49:36 +00:00
|
|
|
}
|