TreeRenderVisitor

Struct TreeRenderVisitor 

Source
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:

  1. Top layer: renders the top borders and connections
  2. Content layer: renders the node content and vertical connections
  3. 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: usize

Maximum total width of the rendered tree

Implementations§

Source§

impl TreeRenderVisitor<'_, '_>

Source

const LTCORNER: &'static str = "┌"

Source

const RTCORNER: &'static str = "┐"

Source

const LDCORNER: &'static str = "└"

Source

const RDCORNER: &'static str = "┘"

Source

const TMIDDLE: &'static str = "┬"

Source

const LMIDDLE: &'static str = "├"

Source

const DMIDDLE: &'static str = "┴"

Source

const VERTICAL: &'static str = "│"

Source

const HORIZONTAL: &'static str = "─"

Source

const NODE_RENDER_WIDTH: usize = 29usize

Source

const MAX_EXTRA_LINES: usize = 30usize

Source

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:

  1. Render top borders and connections
  2. Render node content and vertical connections
  3. Render bottom borders and connections
Source

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
Source

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
Source

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
Source

fn extra_info_separator() -> String

Source

fn remove_padding(s: &str) -> String

Source

pub fn split_up_extra_info( extra_info: &HashMap<String, String>, result: &mut Vec<String>, max_lines: usize, )

Source

fn adjust_text_for_rendering(source: &str, max_render_width: usize) -> String

Adjusts text to fit within the specified width by:

  1. Truncating with ellipsis if too long
  2. Center-aligning within the available space if shorter
Source

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:

  1. Maintaining proper spacing between sibling nodes
  2. Ensuring correct alignment of connections between parents and children
  3. Preserving the tree structure’s visual clarity
Source

fn split_string_buffer(source: &str, result: &mut Vec<String>)

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,