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

    https://github.com/apache/spark/pull/7301#discussion_r34282954
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/pythonUDFs.scala ---
    @@ -220,6 +214,89 @@ object EvaluatePython {
         // TODO(davies): we could improve this by try to cast the object to 
expected type
         case (c, _) => null
       }
    +
    +
    +  private val module = "pyspark.sql.types"
    +
    +  /**
    +   * Pickler for StructType
    +   */
    +  private class StructTypePickler extends IObjectPickler {
    +
    +    private val cls = classOf[StructType]
    +
    +    def register(): Unit = {
    +      Pickler.registerCustomPickler(cls, this)
    +    }
    +
    +    def pickle(obj: Object, out: OutputStream, pickler: Pickler): Unit = {
    +      out.write(Opcodes.GLOBAL)
    +      out.write((module + "\n" + "_parse_datatype_json_string" + 
"\n").getBytes)
    +      val schema = obj.asInstanceOf[StructType]
    +      pickler.save(schema.json)
    +      out.write(Opcodes.TUPLE1)
    +      out.write(Opcodes.REDUCE)
    +    }
    +  }
    +
    +  /**
    +   * Pickler for InternalRow
    +   */
    +  private class RowPickler extends IObjectPickler {
    +
    +    private val cls = classOf[GenericInternalRowWithSchema]
    +
    +    // register this to Pickler and Unpickler
    +    def register(): Unit = {
    +      Pickler.registerCustomPickler(this.getClass, this)
    +      Pickler.registerCustomPickler(cls, this)
    +    }
    +
    +    def pickle(obj: Object, out: OutputStream, pickler: Pickler): Unit = {
    +      if (obj == this) {
    --- End diff --
    
    By saving the same object in a batch, we can benefit from memoiazation of 
Pickler to save a few bytes, or we will have more than 20 bytes for each row.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to