ClickHouse/dbms/DataStreams/SquashingBlockOutputStream.cpp
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

55 lines
1.1 KiB
C++

#include <DataStreams/SquashingBlockOutputStream.h>
namespace DB
{
SquashingBlockOutputStream::SquashingBlockOutputStream(BlockOutputStreamPtr dst, Block header_, size_t min_block_size_rows, size_t min_block_size_bytes)
: output(std::move(dst)), header(std::move(header_)), transform(min_block_size_rows, min_block_size_bytes)
{
}
void SquashingBlockOutputStream::write(const Block & block)
{
SquashingTransform::Result result = transform.add(Block(block).mutateColumns());
if (result.ready)
output->write(header.cloneWithColumns(std::move(result.columns)));
}
void SquashingBlockOutputStream::finalize()
{
if (all_written)
return;
all_written = true;
SquashingTransform::Result result = transform.add({});
if (result.ready && !result.columns.empty())
output->write(header.cloneWithColumns(std::move(result.columns)));
}
void SquashingBlockOutputStream::flush()
{
if (!disable_flush)
finalize();
output->flush();
}
void SquashingBlockOutputStream::writePrefix()
{
output->writePrefix();
}
void SquashingBlockOutputStream::writeSuffix()
{
finalize();
output->writeSuffix();
}
}