aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/AsyncReadCounters.cpp
blob: 816da0d3312ea0c856c6a9fda54bfe3d9c897bd0 (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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <IO/AsyncReadCounters.h>

namespace DB
{

void AsyncReadCounters::dumpToMapColumn(IColumn * column) const
{
    auto * column_map = column ? &typeid_cast<DB::ColumnMap &>(*column) : nullptr;
    if (!column_map)
        return;

    auto & offsets = column_map->getNestedColumn().getOffsets();
    auto & tuple_column = column_map->getNestedData();
    auto & key_column = tuple_column.getColumn(0);
    auto & value_column = tuple_column.getColumn(1);

    size_t size = 0;
    auto load_if_not_empty = [&](const auto & key, const auto & value)
    {
        if (value)
        {
            key_column.insert(key);
            value_column.insert(value);
            ++size;
        }
    };

    std::lock_guard lock(mutex);

    load_if_not_empty("max_parallel_read_tasks", max_parallel_read_tasks);
    load_if_not_empty("max_parallel_prefetch_tasks", max_parallel_prefetch_tasks);
    load_if_not_empty("total_prefetch_tasks", total_prefetch_tasks);

    offsets.push_back(offsets.back() + size);
}

}