ClickHouse/dbms/Processors/Transforms/ReverseTransform.cpp

24 lines
509 B
C++
Raw Normal View History

2019-10-01 16:50:08 +00:00
#include <Processors/Transforms/ReverseTransform.h>
2019-10-14 13:50:16 +00:00
#include <Common/PODArray.h>
2019-10-01 16:50:08 +00:00
namespace DB
{
void ReverseTransform::transform(Chunk & chunk)
{
IColumn::Permutation permutation;
size_t num_rows = chunk.getNumRows();
for (size_t i = 0; i < num_rows; ++i)
permutation.emplace_back(num_rows - 1 - i);
auto columns = chunk.detachColumns();
for (auto & column : columns)
column = column->permute(permutation, 0);
chunk.setColumns(std::move(columns), num_rows);
}
}