You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rednaxelafx <gi...@git.apache.org> on 2017/06/20 18:16:03 UTC

[GitHub] spark pull request #15227: [SPARK-17655][SQL]Remove unused variables declara...

Github user rednaxelafx commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15227#discussion_r123054373
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala ---
    @@ -129,11 +131,17 @@ class CodegenContext {
        *
        * They will be kept as member variables in generated classes like `SpecificProjection`.
        */
    -  val mutableStates: mutable.ArrayBuffer[(String, String, String)] =
    -    mutable.ArrayBuffer.empty[(String, String, String)]
    +  private var mutableStates: mutable.ArrayBuffer[(String, String, String, Boolean)] =
    +    mutable.ArrayBuffer.empty[(String, String, String, Boolean)]
     
    -  def addMutableState(javaType: String, variableName: String, initCode: String): Unit = {
    -    mutableStates += ((javaType, variableName, initCode))
    +  def addMutableState(javaType: String, variableName: String,
    +      initCode: String, isWholeStageResultVar: Boolean = false): Unit = {
    +    if (isWholeStageResultVar) {
    +      mutableStates = mutableStates.filterNot(state => (state._1 == javaType) && state._4)
    +      mutableStates += ((javaType, variableName, initCode, isWholeStageResultVar))
    --- End diff --
    
    So you're effectively letting later-added states to override earlier-added ones that are equivalent and replaceable. Could that be done in a add-if-absent way instead?
    Also, what's the criteria for a state to be "replaceable" in your design? Could you please make that explicit as comment in the code?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org