ClickHouse/src/DataStreams/ReverseBlockInputStream.cpp

43 lines
944 B
C++
Raw Normal View History

#include "ReverseBlockInputStream.h"
2019-10-07 18:56:03 +00:00
#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();
}
2019-04-27 12:43:28 +00:00
IColumn::Permutation permutation;
2019-04-27 12:43:28 +00:00
size_t rows_size = result_block.rows();
for (size_t i = 0; i < rows_size; ++i)
permutation.emplace_back(rows_size - 1 - i);
2019-05-05 20:24:05 +00:00
for (auto & block : result_block)
2019-04-27 12:43:28 +00:00
block.column = block.column->permute(permutation, 0);
return result_block;
}
2019-04-27 12:43:28 +00:00
}