cloud-fan commented on code in PR #45348: URL: https://github.com/apache/spark/pull/45348#discussion_r1514551447
########## sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegenExec.scala: ########## @@ -830,6 +831,24 @@ case class WholeStageCodegenExec(child: SparkPlan)(val codegenStageId: Int) override protected def withNewChildInternal(newChild: SparkPlan): WholeStageCodegenExec = copy(child = newChild)(codegenStageId) + + // Use broadcast if the conf is enabled and the code + comment size exceeds the threshold, + // otherwise, fallback to use cleanedSource directly. The method returns either a + // broadcast variable or the original form of cleanedSource. + private[spark] def tryBroadcastCleanedSource(code: CodeAndComment): + Either[broadcast.Broadcast[CodeAndComment], CodeAndComment] = { + def exceedThreshold(): Boolean = { + code.body.length + code.comment.iterator.map( + e => e._1.length + e._2.length).sum > conf.broadcastCleanedSourceThreshold + } + val enabled = conf.broadcastCleanedSourceThreshold >= 0 + if (enabled && exceedThreshold()) { + SparkContext.getActive.map(sc => scala.util.Left(sc.broadcast(code))) Review Comment: within `SparkPlan`, we can directly call the method `sparkContext`. -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org