2014-01-03 08:20:13 +00:00
|
|
|
#include <DB/Common/ProfileEvents.h>
|
|
|
|
#include <DB/Columns/ColumnString.h>
|
|
|
|
#include <DB/DataTypes/DataTypeString.h>
|
|
|
|
#include <DB/DataTypes/DataTypesNumberFixed.h>
|
|
|
|
#include <DB/DataStreams/OneBlockInputStream.h>
|
|
|
|
#include <DB/Storages/StorageSystemEvents.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
StorageSystemEvents::StorageSystemEvents(const std::string & name_)
|
2015-03-26 23:32:16 +00:00
|
|
|
: name(name_),
|
|
|
|
columns
|
|
|
|
{
|
|
|
|
{"event", new DataTypeString},
|
|
|
|
{"value", new DataTypeUInt64},
|
|
|
|
}
|
2014-01-03 08:20:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
StoragePtr StorageSystemEvents::create(const std::string & name_)
|
|
|
|
{
|
|
|
|
return (new StorageSystemEvents(name_))->thisPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
Block block;
|
|
|
|
|
2015-07-17 01:27:35 +00:00
|
|
|
ColumnWithTypeAndName col_event;
|
2014-01-03 08:20:13 +00:00
|
|
|
col_event.name = "event";
|
|
|
|
col_event.type = new DataTypeString;
|
|
|
|
col_event.column = new ColumnString;
|
|
|
|
block.insert(col_event);
|
|
|
|
|
2015-07-17 01:27:35 +00:00
|
|
|
ColumnWithTypeAndName col_value;
|
2014-01-03 08:20:13 +00:00
|
|
|
col_value.name = "value";
|
|
|
|
col_value.type = new DataTypeUInt64;
|
|
|
|
col_value.column = new ColumnUInt64;
|
|
|
|
block.insert(col_value);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < ProfileEvents::END; ++i)
|
|
|
|
{
|
|
|
|
UInt64 value = ProfileEvents::counters[i];
|
|
|
|
|
|
|
|
if (0 != value)
|
|
|
|
{
|
|
|
|
col_event.column->insert(String(ProfileEvents::getDescription(ProfileEvents::Event(i))));
|
|
|
|
col_value.column->insert(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return BlockInputStreams(1, new OneBlockInputStream(block));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|