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_),
|
|
|
|
columns
|
|
|
|
{
|
|
|
|
{"metric", std::make_shared<DataTypeString>()},
|
|
|
|
{"value", std::make_shared<DataTypeFloat64>()},
|
|
|
|
},
|
|
|
|
async_metrics(async_metrics_)
|
2016-10-24 04:06:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockInputStreams StorageSystemAsynchronousMetrics::read(
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
2017-05-25 01:12:41 +00:00
|
|
|
const ASTPtr & query,
|
2017-04-01 07:20:54 +00:00
|
|
|
const Context & context,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
const size_t max_block_size,
|
2017-06-02 15:54:39 +00:00
|
|
|
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-04-01 07:20:54 +00:00
|
|
|
Block block;
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ColumnWithTypeAndName col_metric;
|
|
|
|
col_metric.name = "metric";
|
|
|
|
col_metric.type = std::make_shared<DataTypeString>();
|
|
|
|
col_metric.column = std::make_shared<ColumnString>();
|
|
|
|
block.insert(col_metric);
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ColumnWithTypeAndName col_value;
|
|
|
|
col_value.name = "value";
|
|
|
|
col_value.type = std::make_shared<DataTypeFloat64>();
|
|
|
|
col_value.column = std::make_shared<ColumnFloat64>();
|
|
|
|
block.insert(col_value);
|
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)
|
|
|
|
{
|
|
|
|
col_metric.column->insert(name_value.first);
|
|
|
|
col_value.column->insert(name_value.second);
|
|
|
|
}
|
2016-10-24 04:06:27 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(block));
|
2016-10-24 04:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|