sandugood commented on code in PR #1778:
URL: 
https://github.com/apache/datafusion-ballista/pull/1778#discussion_r3309985294


##########
ballista/scheduler/src/api/handlers.rs:
##########
@@ -682,6 +687,85 @@ fn task_duration_percentiles(tasks: 
&[Option<TaskSummary>]) -> Option<Percentile
     })
 }
 
+fn format_stage_plan_with_metrics(
+    plan: &dyn ExecutionPlan,
+    stage_metrics: &[MetricsSet],
+    render_tree: bool,
+) -> String {
+    // If it is empty - fall back to render_tree
+    if stage_metrics.is_empty() {
+        return if render_tree {
+            displayable(plan).tree_render().to_string()
+        } else {
+            displayable(plan).indent(false).to_string()
+        };
+    }
+
+    let mut metric_idx = 0;
+    let result = format_node(plan, stage_metrics, &mut metric_idx, 0);
+
+    debug_assert_eq!(
+        metric_idx,
+        stage_metrics.len(),
+        "metric count mismatch: consumed {} but stage_metrics has {}",
+        metric_idx,
+        stage_metrics.len()
+    );
+
+    result
+}
+
+/// Formatting the node in DFS fashion
+/// It is constructed in the same way it is collected (using in-order 
traversal)
+///
+/// For reference how the metrics are collected on the executor's side - see 
ballista-core/utils.rs
+fn format_node(
+    plan: &dyn ExecutionPlan,
+    stage_metrics: &[MetricsSet],
+    metric_idx: &mut usize,
+    indent: usize,
+) -> String {
+    let metrics_set = if plan.metrics().is_some() {
+        let m = stage_metrics.get(*metric_idx);
+        *metric_idx += 1;

Review Comment:
   Addressed this with a comment above the code section
   
   `collect_plan_metrics()`, which behavior I am copying,works only with 
`Some(metrics)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to