askalt commented on issue #19351:
URL: https://github.com/apache/datafusion/issues/19351#issuecomment-3660882807

   Noted:
   
   1) `datafusion-execution` does not depend on physical plan so it would be 
clumsy to store some physical plan specific state within `TaskContext`. 
   
   Decided for now to extend `TaskContext` within `datafusion-physical-plan`:
   
   ```rust
   /// Plan execution context.
   ///
   /// [`ExecutionContext`] contains the state required during a node
   /// execution, including pointers to the children contexts.
   ///
   /// # Note
   ///
   /// A [`ExecutionContext`] tree built on [`ExecutionPlan::execute`] stage
   /// has the same form as the [`ExecutionPlan`] tree itself. It is intended
   /// to store the plan state that is created during the plan execution stage
   /// and should be associated with the plan nodes later. For example, metrics.
   ///
   /// [`ExecutionPlan`]: crate::ExecutionPlan
   /// [`ExecutionPlan::execute`]: crate::ExecutionPlan::execute
   ///
   pub struct ExecutionContext {
       /// Corresponding task context.
       pub task_context: Arc<TaskContext>,
       /// Plan specific state initialized once per execution.
       pub plan_state: OnceAsync<Arc<dyn PlanState>>,
       /// Metrics associated with this plan node.
       pub metrics: ExecutionPlanMetricsSet,
       /// Context for each plan children.
       pub children_context: Vec<Box<ExecutionContext>>,
   }
   ```
   
   Instead of storing `pointer -> state` mapping (which looks clumsy), there is 
the separate tree to keep execution stage related plan state. 
   
   
   


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