| 57 | } |
| 58 | |
| 59 | void QueryStateRecord::Init(const ClientRequestState& query_handle) { |
| 60 | id = query_handle.query_id(); |
| 61 | |
| 62 | const string* plan_str = query_handle.summary_profile()->GetInfoString("Plan"); |
| 63 | if (plan_str != nullptr) { |
| 64 | plan = *plan_str; |
| 65 | // Remove any trailing newlines. |
| 66 | boost::algorithm::trim_if(plan, boost::algorithm::is_any_of("\n")); |
| 67 | } |
| 68 | |
| 69 | stmt = query_handle.sql_stmt(); |
| 70 | effective_user = query_handle.effective_user(); |
| 71 | default_db = query_handle.default_db(); |
| 72 | start_time_us = query_handle.start_time_us(); |
| 73 | end_time_us = query_handle.end_time_us(); |
| 74 | wait_time_ms = query_handle.wait_time_ms(); |
| 75 | client_fetch_wait_time_ns = query_handle.client_fetch_wait_time_ns(); |
| 76 | query_handle.summary_profile()->GetTimeline(&timeline); |
| 77 | |
| 78 | Coordinator* coord = query_handle.GetCoordinator(); |
| 79 | if (coord != nullptr) { |
| 80 | num_completed_scan_ranges = coord->scan_progress().num_complete(); |
| 81 | total_scan_ranges = coord->scan_progress().total(); |
| 82 | num_completed_fragment_instances = coord->query_progress().num_complete(); |
| 83 | total_fragment_instances = coord->query_progress().total(); |
| 84 | const auto& utilization = coord->ComputeQueryResourceUtilization(); |
| 85 | total_peak_mem_usage = utilization.total_peak_mem_usage; |
| 86 | cluster_mem_est = query_handle.schedule()->cluster_mem_est(); |
| 87 | bytes_read = utilization.bytes_read; |
| 88 | bytes_sent = utilization.exchange_bytes_sent + utilization.scan_bytes_sent; |
| 89 | coordinator_slots = get_admission_slots(query_handle.schedule(), true); |
| 90 | executor_slots = get_admission_slots(query_handle.schedule(), false); |
| 91 | has_coord = true; |
| 92 | } else { |
| 93 | num_completed_scan_ranges = 0; |
| 94 | total_scan_ranges = 0; |
| 95 | num_completed_fragment_instances = 0; |
| 96 | total_fragment_instances = 0; |
| 97 | total_peak_mem_usage = 0; |
| 98 | cluster_mem_est = 0; |
| 99 | bytes_read = 0; |
| 100 | bytes_sent = 0; |
| 101 | coordinator_slots = 0; |
| 102 | executor_slots = 0; |
| 103 | has_coord = false; |
| 104 | } |
| 105 | beeswax_query_state = query_handle.BeeswaxQueryState(); |
| 106 | ClientRequestState::RetryState retry_state = query_handle.retry_state(); |
| 107 | if (retry_state == ClientRequestState::RetryState::NOT_RETRIED) { |
| 108 | query_state = beeswax::_QueryState_VALUES_TO_NAMES.find(beeswax_query_state)->second; |
| 109 | } else { |
| 110 | query_state = query_handle.RetryStateToString(retry_state); |
| 111 | } |
| 112 | num_rows_fetched = query_handle.num_rows_fetched(); |
| 113 | query_status = query_handle.query_status(); |
| 114 | |
| 115 | query_handle.query_events()->ToThrift(&event_sequence); |
| 116 |
nothing calls this directly
no test coverage detected