| 310 | } |
| 311 | |
| 312 | void ProgressTable::updateTable(const Block & block) |
| 313 | { |
| 314 | const auto & array_thread_id = typeid_cast<const ColumnUInt64 &>(*block.getByName("thread_id").column).getData(); |
| 315 | const auto & names = typeid_cast<const ColumnString &>(*block.getByName("name").column); |
| 316 | const auto & host_names = typeid_cast<const ColumnString &>(*block.getByName("host_name").column); |
| 317 | const auto & array_values = typeid_cast<const ColumnInt64 &>(*block.getByName("value").column).getData(); |
| 318 | const auto & array_type = typeid_cast<const ColumnInt8 &>(*block.getByName("type").column).getData(); |
| 319 | |
| 320 | const double time_now = watch.elapsedSeconds(); |
| 321 | size_t max_event_name_width = COLUMN_EVENT_NAME.size(); |
| 322 | |
| 323 | std::lock_guard lock{mutex}; |
| 324 | const auto & event_name_to_event = getEventNameToEvent(); |
| 325 | |
| 326 | for (size_t row_num = 0, rows = block.rows(); row_num < rows; ++row_num) |
| 327 | { |
| 328 | auto thread_id = array_thread_id[row_num]; |
| 329 | |
| 330 | /// In ProfileEvents packets thread id 0 specifies common profiling information |
| 331 | /// for all threads executing current query on specific host. So instead of summing per thread |
| 332 | /// consumption it's enough to look for data with thread id 0. |
| 333 | if (thread_id != THREAD_GROUP_ID) |
| 334 | continue; |
| 335 | |
| 336 | std::string name{names.getDataAt(row_num)}; |
| 337 | auto value = array_values[row_num]; |
| 338 | std::string host_name{host_names.getDataAt(row_num)}; |
| 339 | auto type = static_cast<ProfileEvents::Type>(array_type[row_num]); |
| 340 | |
| 341 | /// Got unexpected event name. |
| 342 | if (!event_name_to_event.contains(name)) |
| 343 | continue; |
| 344 | |
| 345 | /// Store non-zero values. |
| 346 | if (value == 0) |
| 347 | continue; |
| 348 | |
| 349 | metrics[name].updateHostValue(host_name, type, value, time_now); |
| 350 | max_event_name_width = std::max(max_event_name_width, name.size()); |
| 351 | } |
| 352 | |
| 353 | column_event_name_width = std::max(column_event_name_width, max_event_name_width + 1); |
| 354 | } |
| 355 | |
| 356 | void ProgressTable::clearTableOutput(WriteBufferFromFileDescriptor & message, std::unique_lock<std::mutex> &) |
| 357 | { |
no test coverage detected