2014-01-03 08:20:13 +00:00
|
|
|
#include <DB/Common/ProfileEvents.h>
|
|
|
|
#include <DB/Columns/ColumnString.h>
|
|
|
|
#include <DB/DataTypes/DataTypeString.h>
|
2017-03-12 10:13:45 +00:00
|
|
|
#include <DB/DataTypes/DataTypesNumber.h>
|
2014-01-03 08:20:13 +00:00
|
|
|
#include <DB/DataStreams/OneBlockInputStream.h>
|
2015-09-24 03:50:09 +00:00
|
|
|
#include <DB/Storages/System/StorageSystemEvents.h>
|
2014-01-03 08:20:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
StorageSystemEvents::StorageSystemEvents(const std::string & name_)
|
2015-03-26 23:32:16 +00:00
|
|
|
: name(name_),
|
|
|
|
columns
|
|
|
|
{
|
2016-05-28 07:48:40 +00:00
|
|
|
{"event", std::make_shared<DataTypeString>()},
|
2016-12-30 16:22:37 +00:00
|
|
|
{"value", std::make_shared<DataTypeUInt64>()}
|
2015-03-26 23:32:16 +00:00
|
|
|
}
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StoragePtr StorageSystemEvents::create(const std::string & name_)
|
|
|
|
{
|
2016-08-26 21:25:05 +00:00
|
|
|
return make_shared(name_);
|
2014-01-03 08:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BlockInputStreams StorageSystemEvents::read(
|
2014-12-17 11:53:17 +00:00
|
|
|
const Names & column_names,
|
|
|
|
ASTPtr query,
|
|
|
|
const Context & context,
|
|
|
|
const Settings & settings,
|
|
|
|
QueryProcessingStage::Enum & processed_stage,
|
|
|
|
const size_t max_block_size,
|
|
|
|
const unsigned threads)
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
|
|
|
check(column_names);
|
|
|
|
processed_stage = QueryProcessingStage::FetchColumns;
|
|
|
|
|
2016-12-30 16:22:37 +00:00
|
|
|
Block block = getSampleBlock();
|
2014-01-03 08:20:13 +00:00
|
|
|
|
2016-10-24 02:02:37 +00:00
|
|
|
for (size_t i = 0, end = ProfileEvents::end(); i < end; ++i)
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
|
|
|
UInt64 value = ProfileEvents::counters[i];
|
|
|
|
|
|
|
|
if (0 != value)
|
|
|
|
{
|
2017-01-02 20:12:12 +00:00
|
|
|
block.getByPosition(0).column->insert(String(ProfileEvents::getDescription(ProfileEvents::Event(i))));
|
|
|
|
block.getByPosition(1).column->insert(value);
|
2014-01-03 08:20:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-28 12:22:22 +00:00
|
|
|
return BlockInputStreams(1, std::make_shared<OneBlockInputStream>(block));
|
2014-01-03 08:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|