2017-04-01 09:19:00 +00:00
|
|
|
#include <Common/ProfileEvents.h>
|
|
|
|
#include <Columns/ColumnString.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataStreams/OneBlockInputStream.h>
|
|
|
|
#include <Storages/System/StorageSystemEvents.h>
|
2014-01-03 08:20:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
StorageSystemEvents::StorageSystemEvents(const std::string & name_)
|
2017-04-01 07:20:54 +00:00
|
|
|
: name(name_),
|
|
|
|
columns
|
|
|
|
{
|
2017-12-02 02:47:12 +00:00
|
|
|
{"event", std::make_shared<DataTypeString>()},
|
|
|
|
{"value", std::make_shared<DataTypeUInt64>()}
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockInputStreams StorageSystemEvents::read(
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & column_names,
|
2017-12-02 02:47:12 +00:00
|
|
|
const SelectQueryInfo &,
|
|
|
|
const Context &,
|
2017-04-01 07:20:54 +00:00
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
2017-12-02 02:47:12 +00:00
|
|
|
const size_t /*max_block_size*/,
|
|
|
|
const unsigned /*num_streams*/)
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
2017-04-01 07:20:54 +00:00
|
|
|
check(column_names);
|
|
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2017-12-16 00:49:03 +00:00
|
|
|
MutableColumns res_columns = getSampleBlock().cloneEmptyColumns();
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
for (size_t i = 0, end = ProfileEvents::end(); i < end; ++i)
|
|
|
|
{
|
|
|
|
UInt64 value = ProfileEvents::counters[i];
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
if (0 != value)
|
|
|
|
{
|
2017-12-16 00:49:03 +00:00
|
|
|
res_columns[0]->insert(String(ProfileEvents::getDescription(ProfileEvents::Event(i))));
|
|
|
|
res_columns[1]->insert(value);
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2017-12-16 00:49:03 +00:00
|
|
|
return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(getSampleBlock().cloneWithColumns(std::move(res_columns))));
|
2014-01-03 08:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|