ClickHouse/dbms/include/DB/Storages/MergeTree/MergeTreeBlockOutputStream.h
Michael Kolupaev d51f9cae03 Merge
2014-05-27 12:43:01 +04:00

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;
};
}