pub struct PlanContext<T> {
pub plan: Arc<dyn ExecutionPlan>,
pub data: T,
pub children: Vec<PlanContext<T>>,
}Expand description
A node context object beneficial for writing optimizer rules.
This context encapsulating an ExecutionPlan node with a payload.
Since each wrapped node has it’s children within both the PlanContext.plan.children(),
as well as separately within the PlanContext.children (which are child nodes wrapped in the context),
it’s important to keep these child plans in sync when performing mutations.
Since there are two ways to access child plans directly -— it’s recommended
to perform mutable operations via Self::update_plan_from_children.
After mutating the PlanContext.children, or after creating the PlanContext,
call update_plan_from_children to sync.
Fields§
§plan: Arc<dyn ExecutionPlan>The execution plan associated with this context.
data: TCustom data payload of the node.
children: Vec<PlanContext<T>>Child contexts of this node.
Implementations§
Source§impl<T> PlanContext<T>
impl<T> PlanContext<T>
pub fn new( plan: Arc<dyn ExecutionPlan>, data: T, children: Vec<PlanContext<T>>, ) -> PlanContext<T>
Sourcepub fn update_plan_from_children(
self,
) -> Result<PlanContext<T>, DataFusionError>
pub fn update_plan_from_children( self, ) -> Result<PlanContext<T>, DataFusionError>
Update the PlanContext.plan.children() from the PlanContext.children,
if the PlanContext.children have been changed.
Source§impl<T> PlanContext<T>where
T: Default,
impl<T> PlanContext<T>where
T: Default,
pub fn new_default(plan: Arc<dyn ExecutionPlan>) -> PlanContext<T>
Trait Implementations§
Source§impl<T> ConcreteTreeNode for PlanContext<T>
impl<T> ConcreteTreeNode for PlanContext<T>
Source§fn children(&self) -> &[PlanContext<T>]
fn children(&self) -> &[PlanContext<T>]
Source§fn take_children(self) -> (PlanContext<T>, Vec<PlanContext<T>>)
fn take_children(self) -> (PlanContext<T>, Vec<PlanContext<T>>)
Source§fn with_new_children(
self,
children: Vec<PlanContext<T>>,
) -> Result<PlanContext<T>, DataFusionError>
fn with_new_children( self, children: Vec<PlanContext<T>>, ) -> Result<PlanContext<T>, DataFusionError>
Source§impl<T> Debug for PlanContext<T>where
T: Debug,
impl<T> Debug for PlanContext<T>where
T: Debug,
Auto Trait Implementations§
impl<T> Freeze for PlanContext<T>where
T: Freeze,
impl<T> !RefUnwindSafe for PlanContext<T>
impl<T> Send for PlanContext<T>where
T: Send,
impl<T> Sync for PlanContext<T>where
T: Sync,
impl<T> Unpin for PlanContext<T>where
T: Unpin,
impl<T> !UnwindSafe for PlanContext<T>
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
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 moreSource§impl<T> TreeNode for Twhere
T: ConcreteTreeNode,
impl<T> TreeNode for Twhere
T: ConcreteTreeNode,
Source§fn apply_children<'n, F>(
&'n self,
f: F,
) -> Result<TreeNodeRecursion, DataFusionError>
fn apply_children<'n, F>( &'n self, f: F, ) -> Result<TreeNodeRecursion, DataFusionError>
Source§fn map_children<F>(self, f: F) -> Result<Transformed<T>, DataFusionError>
fn map_children<F>(self, f: F) -> Result<Transformed<T>, DataFusionError>
Source§fn visit<'n, V>(
&'n self,
visitor: &mut V,
) -> Result<TreeNodeRecursion, DataFusionError>where
V: TreeNodeVisitor<'n, Node = Self>,
fn visit<'n, V>(
&'n self,
visitor: &mut V,
) -> Result<TreeNodeRecursion, DataFusionError>where
V: TreeNodeVisitor<'n, Node = Self>,
TreeNodeVisitor, performing a
depth-first walk of the node and its children. Read moreSource§fn rewrite<R>(
self,
rewriter: &mut R,
) -> Result<Transformed<Self>, DataFusionError>where
R: TreeNodeRewriter<Node = Self>,
fn rewrite<R>(
self,
rewriter: &mut R,
) -> Result<Transformed<Self>, DataFusionError>where
R: TreeNodeRewriter<Node = Self>,
TreeNodeRewriter, performing a
depth-first walk of the node and its children. Read moreSource§fn apply<'n, F>(&'n self, f: F) -> Result<TreeNodeRecursion, DataFusionError>
fn apply<'n, F>(&'n self, f: F) -> Result<TreeNodeRecursion, DataFusionError>
f to the node then each of its children, recursively (a
top-down, pre-order traversal). Read moreSource§fn transform<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
fn transform<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
f
(a bottom-up post-order traversal). Read moreSource§fn transform_down<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
fn transform_down<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
f in a top-down (pre-order)
fashion. Read moreSource§fn transform_up<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
fn transform_up<F>(self, f: F) -> Result<Transformed<Self>, DataFusionError>
f in a bottom-up (post-order)
fashion. Read moreSource§fn transform_down_up<FD, FU>(
self,
f_down: FD,
f_up: FU,
) -> Result<Transformed<Self>, DataFusionError>where
FD: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,
FU: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,
fn transform_down_up<FD, FU>(
self,
f_down: FD,
f_up: FU,
) -> Result<Transformed<Self>, DataFusionError>where
FD: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,
FU: FnMut(Self) -> Result<Transformed<Self>, DataFusionError>,
f_down while traversing the tree top-down
(pre-order), and using f_up while traversing the tree bottom-up
(post-order). Read more