关注 spark技术分享,
撸spark源码 玩spark最佳实践

RuleExecutor Contract — Tree Transformation Rule Executor

RuleExecutor Contract — Tree Transformation Rule Executor

RuleExecutor is the base of rule executors that are responsible for executing a collection of batches (of rules) to transform a TreeNode.

Table 1. RuleExecutor Contract
Property Description

batches

Collection of rule batches, i.e. a sequence of a collection of rules with a name and a strategy that RuleExecutor uses when executed

Note
TreeType is the type of the TreeNode implementation that a RuleExecutor can be executed on, i.e. LogicalPlan, SparkPlan, Expression or a combination thereof.
Table 2. RuleExecutors (Direct Implementations)
RuleExecutor Description

Analyzer

Logical query plan analyzer

ExpressionCanonicalizer

Optimizer

Generic logical query plan optimizer

Applying Rule Batches to TreeNode — execute Method

execute iterates over rule batches and applies rules sequentially to the input plan.

execute tracks the number of iterations and the time of executing each rule (with a plan).

When a rule changes a plan, you should see the following TRACE message in the logs:

After the number of iterations has reached the number of iterations for the batch’s Strategy it stops execution and prints out the following WARN message to the logs:

When the plan has not changed (after applying rules), you should see the following TRACE message in the logs and execute moves on to applying the rules in the next batch. The moment is called fixed point (i.e. when the execution converges).

After the batch finishes, if the plan has been changed by the rules, you should see the following DEBUG message in the logs:

Otherwise, when the rules had no changes to a plan, you should see the following TRACE message in the logs:

Rule Batch — Collection of Rules

Batch is a named collection of rules with a strategy.

Batch takes the following when created:

Batch Execution Strategy

Strategy is the base of the batch execution strategies that indicate the maximum number of executions (aka maxIterations).

Table 3. Strategies
Strategy Description

Once

A strategy that runs only once (with maxIterations as 1)

FixedPoint

A strategy that runs until fix point (i.e. converge) or maxIterations times, whichever comes first

isPlanIntegral Method

isPlanIntegral simply returns true.

Note
isPlanIntegral is used exclusively when RuleExecutor is requested to execute.
赞(0) 打赏
未经允许不得转载:spark技术分享 » RuleExecutor Contract — Tree Transformation Rule Executor
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏