ClickHouse/dbms/include/DB/Storages/MergeTree/MergeTreeBlockOutputStream.h
Michael Kolupaev 1983ac540b Merge
2014-07-03 12:51:11 +04:00

34 lines
736 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);
storage.merge_task_handle->wake();
}
}
private:
StorageMergeTree & storage;
};
}