2017-04-28 18:33:31 +00:00
|
|
|
#include <Dictionaries/DictionaryBlockInputStreamBase.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-05-26 16:08:56 +00:00
|
|
|
DictionaryBlockInputStreamBase::DictionaryBlockInputStreamBase(size_t rows_count, size_t max_block_size)
|
|
|
|
: rows_count(rows_count), max_block_size(max_block_size), next_row(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-04-28 18:33:31 +00:00
|
|
|
String DictionaryBlockInputStreamBase::getID() const
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2017-05-30 15:02:44 +00:00
|
|
|
ss << static_cast<const void*>(this);
|
2017-04-28 18:33:31 +00:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
Block DictionaryBlockInputStreamBase::readImpl()
|
|
|
|
{
|
2017-05-26 16:08:56 +00:00
|
|
|
if (next_row == rows_count)
|
2017-04-28 18:33:31 +00:00
|
|
|
return Block();
|
|
|
|
|
2017-05-26 16:08:56 +00:00
|
|
|
size_t block_size = std::min<size_t>(max_block_size, rows_count - next_row);
|
|
|
|
Block block = getBlock(next_row, block_size);
|
|
|
|
next_row += block_size;
|
2017-04-28 18:33:31 +00:00
|
|
|
return block;
|
|
|
|
}
|
|
|
|
|
2017-05-26 16:08:56 +00:00
|
|
|
}
|