Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ private[spark] object LogKeys {
case object RPC_ENDPOINT_REF extends LogKey
case object RPC_MESSAGE_CAPACITY extends LogKey
case object RPC_SSL_ENABLED extends LogKey
case object RULE_EXECUTOR_NAME extends LogKey
case object RULE_NAME extends LogKey
case object RUN_ID extends LogKey
case object SCALA_VERSION extends LogKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ class PlanChangeLogger[TreeType <: TreeNode[_]] extends Logging {
}
}

def logMetrics(metrics: QueryExecutionMetrics): Unit = {
def logMetrics(name: String, metrics: QueryExecutionMetrics): Unit = {
val totalTime = metrics.time / NANOS_PER_MILLIS.toDouble
val totalTimeEffective = metrics.timeEffective / NANOS_PER_MILLIS.toDouble
// scalastyle:off line.size.limit
val message: MessageWithContext =
log"""
|=== Metrics of Executed Rules ===
|=== Metrics of Executed Rules ${MDC(RULE_EXECUTOR_NAME, name)} ===
|Total number of runs: ${MDC(NUM_RULE_OF_RUNS, metrics.numRuns)}
|Total time: ${MDC(TOTAL_TIME, totalTime)} ms
|Total number of effective runs: ${MDC(NUM_EFFECTIVE_RULE_OF_RUNS, metrics.numEffectiveRuns)}
Expand All @@ -118,6 +118,12 @@ class PlanChangeLogger[TreeType <: TreeNode[_]] extends Logging {

abstract class RuleExecutor[TreeType <: TreeNode[_]] extends Logging {

/** Name for this rule executor, automatically inferred based on class name. */
val name: String = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about to convert it to a method with protected to allow override in sub-classes for better names.

Copy link
Contributor Author

@panbingkun panbingkun Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, let me update it now, thanks!

val className = getClass.getName
if (className endsWith "$") className.dropRight(1) else className
}

/**
* An execution strategy for rules that indicates the maximum number of executions. If the
* execution reaches fix point (i.e. converge) before maxIterations, it will stop.
Expand Down Expand Up @@ -291,7 +297,7 @@ abstract class RuleExecutor[TreeType <: TreeNode[_]] extends Logging {

planChangeLogger.logBatch(batch.name, batchStartPlan, curPlan)
}
planChangeLogger.logMetrics(RuleExecutor.getCurrentMetrics() - beforeMetrics)
planChangeLogger.logMetrics(name, RuleExecutor.getCurrentMetrics() - beforeMetrics)

curPlan
}
Expand Down