aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Processors/Transforms/ReverseTransform.cpp
blob: 66b774ab50d529cb77ec34fc22dc4a6081dfb674 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <Processors/Transforms/ReverseTransform.h>
#include <Common/PODArray.h>

namespace DB
{

void ReverseTransform::transform(Chunk & chunk)
{
    size_t num_rows = chunk.getNumRows();
    IColumn::Permutation permutation(num_rows);

    for (size_t i = 0; i < num_rows; ++i)
        permutation[i] = num_rows - 1 - i;

    auto columns = chunk.detachColumns();

    for (auto & column : columns)
        column = column->permute(permutation, 0);

    chunk.setColumns(std::move(columns), num_rows);
}

}