mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 01:12:12 +00:00
97f2a2213e
* Move some code outside dbms/src folder * Fix paths
43 lines
944 B
C++
43 lines
944 B
C++
#include "ReverseBlockInputStream.h"
|
|
|
|
#include <Common/PODArray.h>
|
|
|
|
namespace DB
|
|
{
|
|
ReverseBlockInputStream::ReverseBlockInputStream(const BlockInputStreamPtr & input)
|
|
{
|
|
children.push_back(input);
|
|
}
|
|
|
|
String ReverseBlockInputStream::getName() const
|
|
{
|
|
return "Reverse";
|
|
}
|
|
|
|
Block ReverseBlockInputStream::getHeader() const
|
|
{
|
|
return children.at(0)->getHeader();
|
|
}
|
|
|
|
Block ReverseBlockInputStream::readImpl()
|
|
{
|
|
auto result_block = children.back()->read();
|
|
|
|
if (!result_block)
|
|
{
|
|
return Block();
|
|
}
|
|
|
|
IColumn::Permutation permutation;
|
|
|
|
size_t rows_size = result_block.rows();
|
|
for (size_t i = 0; i < rows_size; ++i)
|
|
permutation.emplace_back(rows_size - 1 - i);
|
|
|
|
for (auto & block : result_block)
|
|
block.column = block.column->permute(permutation, 0);
|
|
|
|
return result_block;
|
|
}
|
|
}
|