#include #include #include #include #include #include namespace DB { StorageSystemEvents::StorageSystemEvents(const std::string & name_) : name(name_), columns { {"event", std::make_shared()}, {"value", std::make_shared()}, } { } StoragePtr StorageSystemEvents::create(const std::string & name_) { return make_shared(name_); } BlockInputStreams StorageSystemEvents::read( 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) { check(column_names); processed_stage = QueryProcessingStage::FetchColumns; Block block; ColumnWithTypeAndName col_event; col_event.name = "event"; col_event.type = std::make_shared(); col_event.column = std::make_shared(); block.insert(col_event); ColumnWithTypeAndName col_value; col_value.name = "value"; col_value.type = std::make_shared(); col_value.column = std::make_shared(); block.insert(col_value); for (size_t i = 0, end = ProfileEvents::end(); i < 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, std::make_shared(block)); } }