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

    https://github.com/apache/spark/pull/19603#discussion_r147581601
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -591,18 +591,40 @@ case class MapObjects private(
           case _ => inputData.dataType
         }
     
    -    val (getLength, getLoopVar) = inputDataType match {
    +    val (getLength, prepareLoop, getLoopVar) = inputDataType match {
           case ObjectType(cls) if classOf[Seq[_]].isAssignableFrom(cls) =>
    -        s"${genInputData.value}.size()" -> 
s"${genInputData.value}.apply($loopIndex)"
    +        val it = ctx.freshName("it")
    +        (
    +          s"${genInputData.value}.size()",
    --- End diff --
    
    Is it OK with us for `size()` to take `O(n)` in some implementations of 
`Seq`?
    Since this is out of the loop, it is not the worst, but it is not good. It 
would be better to iterate a loop using `hasNext()`.


---

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

Reply via email to