mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
33 lines
698 B
C++
33 lines
698 B
C++
#pragma once
|
|
|
|
#include <DB/Storages/StorageMergeTree.h>
|
|
#include <iomanip>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class MergeTreeBlockOutputStream : public IBlockOutputStream
|
|
{
|
|
public:
|
|
MergeTreeBlockOutputStream(StorageMergeTree & storage_)
|
|
: storage(storage_) {}
|
|
|
|
void write(const Block & block)
|
|
{
|
|
auto part_blocks = storage.writer.splitBlockIntoParts(block);
|
|
for (auto & current_block : part_blocks)
|
|
{
|
|
storage.data.delayInsertIfNeeded();
|
|
|
|
UInt64 temp_index = storage.increment.get();
|
|
MergeTreeData::MutableDataPartPtr part = storage.writer.writeTempPart(current_block, temp_index);
|
|
storage.data.renameTempPartAndAdd(part, &storage.increment);
|
|
}
|
|
}
|
|
|
|
private:
|
|
StorageMergeTree & storage;
|
|
};
|
|
|
|
}
|