ClickHouse/dbms/DataStreams/SquashingBlockInputStream.cpp

37 lines
854 B
C++
Raw Normal View History

#include <DataStreams/SquashingBlockInputStream.h>
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, bool reserve_memory)
: header(src->getHeader()), transform(min_block_size_rows, min_block_size_bytes, reserve_memory)
{
children.emplace_back(src);
}
Block SquashingBlockInputStream::readImpl()
{
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());
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
}
}
}
}