ClickHouse/src/Storages/MergeTree/MergeTreeDataWriter.h

57 lines
1.4 KiB
C++
Raw Normal View History

2013-04-24 10:31:32 +00:00
#pragma once
#include <Core/Block.h>
#include <Core/Row.h>
#include <IO/WriteBufferFromFile.h>
2018-12-28 18:15:26 +00:00
#include <Compression/CompressedWriteBuffer.h>
2013-09-15 01:10:16 +00:00
#include <Columns/ColumnsNumber.h>
2013-09-15 01:10:16 +00:00
#include <Interpreters/sortBlock.h>
2013-09-15 01:10:16 +00:00
#include <Storages/MergeTree/MergeTreeData.h>
2013-04-24 10:31:32 +00:00
2013-09-15 01:10:16 +00:00
2013-04-24 10:31:32 +00:00
namespace DB
{
2014-03-09 17:36:01 +00:00
struct BlockWithPartition
2014-03-13 17:44:00 +00:00
{
Block block;
Row partition;
BlockWithPartition(Block && block_, Row && partition_)
: block(block_), partition(std::move(partition_))
{
}
2014-03-13 17:44:00 +00:00
};
using BlocksWithPartition = std::vector<BlockWithPartition>;
2014-03-13 17:44:00 +00:00
2018-05-07 02:01:11 +00:00
/** Writes new parts of data to the merge tree.
2014-03-13 12:48:07 +00:00
*/
class MergeTreeDataWriter
{
public:
2020-05-30 21:57:37 +00:00
MergeTreeDataWriter(MergeTreeData & data_) : data(data_), log(&Poco::Logger::get(data.getLogName() + " (Writer)")) {}
2014-03-13 12:48:07 +00:00
/** Split the block to blocks, each of them must be written as separate part.
* (split rows by partition)
* Works deterministically: if same block was passed, function will return same result in same order.
*/
BlocksWithPartition splitBlockIntoParts(const Block & block, size_t max_parts, const StorageMetadataPtr & metadata_snapshot);
2014-03-13 12:48:07 +00:00
/** All rows must correspond to same partition.
* Returns part with unique name starting with 'tmp_', yet not added to MergeTreeData.
*/
MergeTreeData::MutableDataPartPtr writeTempPart(BlockWithPartition & block, const StorageMetadataPtr & metadata_snapshot);
2014-03-13 12:48:07 +00:00
private:
MergeTreeData & data;
2014-03-03 18:55:39 +00:00
2020-05-30 21:57:37 +00:00
Poco::Logger * log;
2013-04-24 10:31:32 +00:00
};
2014-03-13 17:44:00 +00:00
2013-04-24 10:31:32 +00:00
}