struct TreeRenderVisitor<'a, 'b> {
f: &'a mut Formatter<'b>,
maximum_render_width: usize,
}Expand description
This module implements a tree-like art renderer for execution plans, based on DuckDB’s implementation: https://github.com/duckdb/duckdb/blob/main/src/include/duckdb/common/tree_renderer/text_tree_renderer.hpp
The rendered output looks like this:
┌───────────────────────────┐
│ CoalesceBatchesExec │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│ HashJoinExec ├──────────────┐
└─────────────┬─────────────┘ │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│ DataSourceExec ││ DataSourceExec │
└───────────────────────────┘└───────────────────────────┘The renderer uses a three-layer approach for each node:
- Top layer: renders the top borders and connections
- Content layer: renders the node content and vertical connections
- Bottom layer: renders the bottom borders and connections
Each node is rendered in a box of fixed width (NODE_RENDER_WIDTH).
Fields§
§f: &'a mut Formatter<'b>Write to this formatter
maximum_render_width: usizeMaximum total width of the rendered tree
Implementations§
Source§impl TreeRenderVisitor<'_, '_>
impl TreeRenderVisitor<'_, '_>
const LTCORNER: &'static str = "┌"
const RTCORNER: &'static str = "┐"
const LDCORNER: &'static str = "└"
const RDCORNER: &'static str = "┘"
const TMIDDLE: &'static str = "┬"
const LMIDDLE: &'static str = "├"
const DMIDDLE: &'static str = "┴"
const VERTICAL: &'static str = "│"
const HORIZONTAL: &'static str = "─"
const NODE_RENDER_WIDTH: usize = 29usize
const MAX_EXTRA_LINES: usize = 30usize
Sourcepub fn visit(&mut self, plan: &dyn ExecutionPlan) -> Result<(), Error>
pub fn visit(&mut self, plan: &dyn ExecutionPlan) -> Result<(), Error>
Main entry point for rendering an execution plan as a tree. The rendering process happens in three stages for each level of the tree:
- Render top borders and connections
- Render node content and vertical connections
- Render bottom borders and connections
Sourcefn render_top_layer(&mut self, root: &RenderTree, y: usize) -> Result<(), Error>
fn render_top_layer(&mut self, root: &RenderTree, y: usize) -> Result<(), Error>
Renders the top layer of boxes at the given y-level of the tree. This includes:
- Top corners (┌─┐) for nodes
- Horizontal connections between nodes
- Vertical connections to parent nodes
Sourcefn render_box_content(
&mut self,
root: &RenderTree,
y: usize,
) -> Result<(), Error>
fn render_box_content( &mut self, root: &RenderTree, y: usize, ) -> Result<(), Error>
Renders the content layer of boxes at the given y-level of the tree. This includes:
- Node names and extra information
- Vertical borders (│) for boxes
- Vertical connections between nodes
Sourcefn render_bottom_layer(
&mut self,
root: &RenderTree,
y: usize,
) -> Result<(), Error>
fn render_bottom_layer( &mut self, root: &RenderTree, y: usize, ) -> Result<(), Error>
Renders the bottom layer of boxes at the given y-level of the tree. This includes:
- Bottom corners (└─┘) for nodes
- Horizontal connections between nodes
- Vertical connections to child nodes
fn extra_info_separator() -> String
fn remove_padding(s: &str) -> String
pub fn split_up_extra_info( extra_info: &HashMap<String, String>, result: &mut Vec<String>, max_lines: usize, )
Sourcefn adjust_text_for_rendering(source: &str, max_render_width: usize) -> String
fn adjust_text_for_rendering(source: &str, max_render_width: usize) -> String
Adjusts text to fit within the specified width by:
- Truncating with ellipsis if too long
- Center-aligning within the available space if shorter
Sourcefn should_render_whitespace(root: &RenderTree, x: usize, y: usize) -> bool
fn should_render_whitespace(root: &RenderTree, x: usize, y: usize) -> bool
Determines if whitespace should be rendered at a given position. This is important for:
- Maintaining proper spacing between sibling nodes
- Ensuring correct alignment of connections between parents and children
- Preserving the tree structure’s visual clarity
fn split_string_buffer(source: &str, result: &mut Vec<String>)
fn can_split_on_this_char(c: char) -> bool
Auto Trait Implementations§
impl<'a, 'b> Freeze for TreeRenderVisitor<'a, 'b>
impl<'a, 'b> !RefUnwindSafe for TreeRenderVisitor<'a, 'b>
impl<'a, 'b> !Send for TreeRenderVisitor<'a, 'b>
impl<'a, 'b> !Sync for TreeRenderVisitor<'a, 'b>
impl<'a, 'b> Unpin for TreeRenderVisitor<'a, 'b>
impl<'a, 'b> !UnwindSafe for TreeRenderVisitor<'a, 'b>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more