ClickHouse/dbms/src/DataStreams/SquashingBlockOutputStream.cpp

54 lines
990 B
C++
Raw Normal View History

#include <DataStreams/SquashingBlockOutputStream.h>
2016-07-07 01:57:48 +00:00
namespace DB
{
SquashingBlockOutputStream::SquashingBlockOutputStream(BlockOutputStreamPtr & dst, size_t min_block_size_rows, size_t min_block_size_bytes)
: output(dst), transform(min_block_size_rows, min_block_size_bytes)
2016-07-07 01:57:48 +00:00
{
}
void SquashingBlockOutputStream::write(const Block & block)
{
SquashingTransform::Result result = transform.add(Block(block));
if (result.ready)
output->write(result.block);
2016-07-07 01:57:48 +00:00
}
void SquashingBlockOutputStream::finalize()
{
if (all_written)
return;
2016-07-07 01:57:48 +00:00
all_written = true;
2016-07-07 01:57:48 +00:00
SquashingTransform::Result result = transform.add({});
if (result.ready && result.block)
output->write(result.block);
2016-07-07 01:57:48 +00:00
}
void SquashingBlockOutputStream::flush()
{
finalize();
output->flush();
2016-07-07 01:57:48 +00:00
}
void SquashingBlockOutputStream::writePrefix()
{
output->writePrefix();
2016-07-07 01:57:48 +00:00
}
void SquashingBlockOutputStream::writeSuffix()
{
finalize();
output->writeSuffix();
2016-07-07 01:57:48 +00:00
}
}