ClickHouse/src/Storages/MergeTree/IMergeTreeDataPartWriter.h
2020-12-14 17:27:39 +03:00

55 lines
1.7 KiB
C++

#pragma once
#include <IO/WriteBufferFromFile.h>
#include <IO/WriteBufferFromFileBase.h>
#include <Compression/CompressedWriteBuffer.h>
#include <IO/HashingWriteBuffer.h>
#include <Storages/MergeTree/MergeTreeData.h>
#include <DataStreams/IBlockOutputStream.h>
#include <Storages/MergeTree/IMergeTreeDataPart.h>
#include <Disks/IDisk.h>
namespace DB
{
Block getBlockAndPermute(const Block & block, const Names & names, const IColumn::Permutation * permutation);
Block permuteBlockIfNeeded(const Block & block, const IColumn::Permutation * permutation);
/// Writes data part to disk in different formats.
/// Calculates and serializes primary and skip indices if needed.
class IMergeTreeDataPartWriter : private boost::noncopyable
{
public:
IMergeTreeDataPartWriter(
const MergeTreeData::DataPartPtr & data_part_,
const NamesAndTypesList & columns_list_,
const StorageMetadataPtr & metadata_snapshot_,
const MergeTreeWriterSettings & settings_,
const MergeTreeIndexGranularity & index_granularity_ = {});
virtual ~IMergeTreeDataPartWriter();
virtual void write(const Block & block, const IColumn::Permutation * permutation) = 0;
virtual void finish(IMergeTreeDataPart::Checksums & checksums, bool sync) = 0;
Columns releaseIndexColumns();
const MergeTreeIndexGranularity & getIndexGranularity() const { return index_granularity; }
protected:
const MergeTreeData::DataPartPtr data_part;
const MergeTreeData & storage;
const StorageMetadataPtr metadata_snapshot;
const NamesAndTypesList columns_list;
const MergeTreeWriterSettings settings;
MergeTreeIndexGranularity index_granularity;
const bool with_final_mark;
MutableColumns index_columns;
};
}