2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/System/StorageSystemAsynchronousMetrics.h>
|
|
|
|
|
|
|
|
#include <Interpreters/AsynchronousMetrics.h>
|
|
|
|
#include <Columns/ColumnsNumber.h>
|
|
|
|
#include <Columns/ColumnString.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataStreams/OneBlockInputStream.h>
|
2016-10-24 04:06:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
StorageSystemAsynchronousMetrics::StorageSystemAsynchronousMetrics(const std::string & name_, const AsynchronousMetrics & async_metrics_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: name(name_),
|
|
|
|
async_metrics(async_metrics_)
|
2016-10-24 04:06:27 +00:00
|
|
|
{
|
2018-03-13 14:18:11 +00:00
|
|
|
setColumns(ColumnsDescription({
|
2018-01-25 14:42:39 +00:00
|
|
|
{"metric", std::make_shared<DataTypeString>()},
|
|
|
|
{"value", std::make_shared<DataTypeFloat64>()},
|
2018-03-13 14:18:11 +00:00
|
|
|
}));
|
2016-10-24 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockInputStreams StorageSystemAsynchronousMetrics::read(
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
2017-12-01 21:51:50 +00:00
|
|
|
const SelectQueryInfo &,
|
|
|
|
const Context &,
|
2017-04-01 07:20:54 +00:00
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
2017-12-01 21:51:50 +00:00
|
|
|
const size_t /*max_block_size*/,
|
|
|
|
const unsigned /*num_streams*/)
|
2016-10-24 04:06:27 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
check(column_names);
|
|
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-12-16 00:49:03 +00:00
|
|
|
MutableColumns res_columns = getSampleBlock().cloneEmptyColumns();
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
auto async_metrics_values = async_metrics.getValues();
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (const auto & name_value : async_metrics_values)
|
|
|
|
{
|
2017-12-16 00:49:03 +00:00
|
|
|
res_columns[0]->insert(name_value.first);
|
|
|
|
res_columns[1]->insert(name_value.second);
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-12-16 00:49:03 +00:00
|
|
|
return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(getSampleBlock().cloneWithColumns(std::move(res_columns))));
|
2016-10-24 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|