2018-06-20 17:49:52 +00:00
|
|
|
#include "ProfileEventsExt.h"
|
|
|
|
#include <Common/typeid_cast.h>
|
|
|
|
#include <Columns/ColumnsNumber.h>
|
|
|
|
#include <Columns/ColumnString.h>
|
|
|
|
#include <Columns/ColumnArray.h>
|
2021-01-05 10:10:19 +00:00
|
|
|
#include <Columns/ColumnMap.h>
|
2018-06-20 17:49:52 +00:00
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypeArray.h>
|
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
{
|
|
|
|
|
2021-10-13 20:52:39 +00:00
|
|
|
std::shared_ptr<DB::DataTypeEnum8> TypeEnum = std::make_shared<DB::DataTypeEnum8>(DB::DataTypeEnum8::Values{
|
|
|
|
{ "increment", static_cast<Int8>(INCREMENT)},
|
|
|
|
{ "gauge", static_cast<Int8>(GAUGE)},
|
|
|
|
});
|
|
|
|
|
2018-06-20 17:49:52 +00:00
|
|
|
/// Put implementation here to avoid extra linking dependencies for clickhouse_common_io
|
2021-10-11 15:56:23 +00:00
|
|
|
void dumpToMapColumn(const Counters::Snapshot & counters, DB::IColumn * column, bool nonzero_only)
|
2018-06-20 17:49:52 +00:00
|
|
|
{
|
2021-01-05 10:10:19 +00:00
|
|
|
auto * column_map = column ? &typeid_cast<DB::ColumnMap &>(*column) : nullptr;
|
|
|
|
if (!column_map)
|
|
|
|
return;
|
2018-06-20 17:49:52 +00:00
|
|
|
|
2021-01-05 10:10:19 +00:00
|
|
|
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);
|
2018-06-20 17:49:52 +00:00
|
|
|
|
2021-01-05 10:10:19 +00:00
|
|
|
size_t size = 0;
|
2018-06-20 17:49:52 +00:00
|
|
|
for (Event event = 0; event < Counters::num_counters; ++event)
|
|
|
|
{
|
2021-10-11 15:56:23 +00:00
|
|
|
UInt64 value = counters[event];
|
2018-06-20 17:49:52 +00:00
|
|
|
|
|
|
|
if (nonzero_only && 0 == value)
|
|
|
|
continue;
|
|
|
|
|
2021-01-05 10:10:19 +00:00
|
|
|
const char * desc = ProfileEvents::getName(event);
|
|
|
|
key_column.insertData(desc, strlen(desc));
|
|
|
|
value_column.insert(value);
|
|
|
|
size++;
|
2018-06-20 17:49:52 +00:00
|
|
|
}
|
2021-06-28 11:42:21 +00:00
|
|
|
|
2021-01-05 10:10:19 +00:00
|
|
|
offsets.push_back(offsets.back() + size);
|
2018-06-20 17:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|