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

    https://github.com/apache/spark/pull/13909#discussion_r91039840
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala
 ---
    @@ -132,50 +153,80 @@ case class CreateMap(children: Seq[Expression]) 
extends Expression {
         new ArrayBasedMapData(new GenericArrayData(keyArray), new 
GenericArrayData(valueArray))
       }
     
    +  private def getAccessors(ctx: CodegenContext, dt: DataType, array: 
String,
    +      isPrimitive : Boolean, size: Int): (String, String, String) = {
    +    if (!isPrimitive) {
    +      val arrayClass = classOf[GenericArrayData].getName
    +      ctx.addMutableState("Object[]", array, s"this.$array = null;")
    +      (s"new $arrayClass($array)",
    +        s"$array = new Object[${size}];", s"this.$array = null;")
    +    } else {
    +      val unsafeArrayClass = classOf[UnsafeArrayData].getName
    +      val javaDataType = ctx.javaType(dt)
    +      ctx.addMutableState(s"${javaDataType}[]", array,
    +        s"this.$array = new ${javaDataType}[${size}];")
    +      (s"$unsafeArrayClass.fromPrimitiveArray($array)", "", "")
    --- End diff --
    
    I left the conventional approach for non-primitive cases. Now, I tried to 
allocate an object only once for non-primitive cases, too.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to