2017-04-01 09:19:00 +00:00
|
|
|
#include <DataStreams/SquashingBlockInputStream.h>
|
2016-07-01 21:02:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2018-09-09 02:23:24 +00:00
|
|
|
SquashingBlockInputStream::SquashingBlockInputStream(
|
|
|
|
const BlockInputStreamPtr & src, size_t min_block_size_rows, size_t min_block_size_bytes)
|
2019-09-26 18:51:17 +00:00
|
|
|
: header(src->getHeader()), transform(min_block_size_rows, min_block_size_bytes, true)
|
2016-07-01 21:02:13 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
children.emplace_back(src);
|
2016-07-01 21:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Block SquashingBlockInputStream::readImpl()
|
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
if (all_read)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
Block block = children[0]->read();
|
|
|
|
if (!block)
|
|
|
|
all_read = true;
|
|
|
|
|
2018-09-08 19:23:48 +00:00
|
|
|
SquashingTransform::Result result = transform.add(block.mutateColumns());
|
2017-04-01 07:20:54 +00:00
|
|
|
if (result.ready)
|
2018-09-09 05:47:27 +00:00
|
|
|
{
|
|
|
|
if (result.columns.empty())
|
|
|
|
return {};
|
2018-09-09 02:23:24 +00:00
|
|
|
return header.cloneWithColumns(std::move(result.columns));
|
2018-09-09 05:47:27 +00:00
|
|
|
}
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2016-07-01 21:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|