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

    https://github.com/apache/spark/pull/20751#discussion_r172828460
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -105,6 +105,66 @@ trait InvokeLike extends Expression with 
NonSQLExpression {
       }
     }
     
    +/**
    + * Common trait for [[DecodeUsingSerializer]] and [[EncodeUsingSerializer]]
    + */
    +trait BaseSerializer {
    +  /**
    +   * If true, Kryo serialization is used, otherwise the Java one is used
    +   */
    +  val kryo: Boolean
    +
    +  /**
    +   * The serializer instance to be used for serialization/deserialization
    +   */
    +  lazy val serializerInstance = {
    +    val conf = Option(SparkEnv.get).map(_.conf).getOrElse(new SparkConf)
    +    val s = if (kryo) {
    +        new KryoSerializer(conf)
    +      } else {
    +        new JavaSerializer(conf)
    +      }
    +    s.newInstance()
    +  }
    +
    +  /**
    +   * The name of the variable referencing the serializer, which is added 
with
    +   * `addImmutableSerializerIfNeeded`
    +   */
    +  lazy val serializerVarName = if (kryo) {
    --- End diff --
    
    Let's make `addImmutableSerializerIfNeeded` return the serializer name. No 
need for a separate method.


---

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

Reply via email to