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

    https://github.com/apache/spark/pull/18659#discussion_r127929933
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/arrow/ArrowConverters.scala
 ---
    @@ -132,6 +135,61 @@ private[sql] object ArrowConverters {
         }
       }
     
    +  private[sql] def fromPayloadIterator(iter: Iterator[ArrowPayload]): 
Iterator[InternalRow] = {
    +    new Iterator[InternalRow] {
    +      private val _allocator = new RootAllocator(Long.MaxValue)
    +      private var _reader: ArrowFileReader = _
    +      private var _root: VectorSchemaRoot = _
    +      private var _index = 0
    +
    +      loadNextBatch()
    +
    +      override def hasNext: Boolean = _root != null && _index < 
_root.getRowCount
    +
    +      override def next(): InternalRow = {
    +        val fields = _root.getFieldVectors.asScala
    +
    +        val genericRowData = fields.map { field =>
    +          field.getAccessor.getObject(_index)
    +        }.toArray[Any]
    --- End diff --
    
    As additional performance optimization, can we reuse `InternalRow` object 
that `next()` method returns?
    For example, I think that this 
[`next()`](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/WholeStageCodegenExec.scala#L399)
 reuses `UnsafeRow` that is allocated in Java code, which is generated at [here 
](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeProjection.scala#L319),
 as an instance variable.


---
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