MCPcopy Create free account
hub / github.com/apache/datafusion / get_tree_width_height

Function get_tree_width_height

datafusion/physical-plan/src/render_tree.rs:143–163  ·  view source on GitHub ↗

Calculates the required dimensions of the tree. This ensures we allocate enough space for the entire tree structure. # Arguments `plan` - The execution plan to measure # Returns A tuple of (width, height) representing the dimensions needed for the tree

(plan: &dyn ExecutionPlan)

Source from the content-addressed store, hash-verified

141/// # Returns
142/// * A tuple of (width, height) representing the dimensions needed for the tree
143fn get_tree_width_height(plan: &dyn ExecutionPlan) -> (usize, usize) {
144 let children = plan.children();
145
146 // Leaf nodes take up 1x1 space
147 if children.is_empty() {
148 return (1, 1);
149 }
150
151 let mut width = 0;
152 let mut height = 0;
153
154 for child in children {
155 let (child_width, child_height) = get_tree_width_height(child.as_ref());
156 width += child_width;
157 height = cmp::max(height, child_height);
158 }
159
160 height += 1;
161
162 (width, height)
163}
164
165fn fmt_display(plan: &dyn ExecutionPlan) -> impl fmt::Display + '_ {
166 struct Wrapper<'a> {

Callers 1

create_treeMethod · 0.85

Calls 4

maxFunction · 0.85
childrenMethod · 0.45
is_emptyMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…