2017-04-01 09:19:00 +00:00
|
|
|
#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)
|
2017-04-01 07:20:54 +00:00
|
|
|
: 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)
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
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()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (all_written)
|
|
|
|
return;
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
all_written = true;
|
2016-07-07 01:57:48 +00:00
|
|
|
|
2017-04-01 07:20:54 +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()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
finalize();
|
|
|
|
output->flush();
|
2016-07-07 01:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SquashingBlockOutputStream::writePrefix()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
output->writePrefix();
|
2016-07-07 01:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SquashingBlockOutputStream::writeSuffix()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
finalize();
|
|
|
|
output->writeSuffix();
|
2016-07-07 01:57:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|