pavel0fadeev commented on code in PR #48110:
URL: https://github.com/apache/spark/pull/48110#discussion_r1760311401


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/state/StatePartitionReader.scala:
##########
@@ -178,44 +176,75 @@ class StatePartitionReader(
     }
   }
 
+  private def processListStateEntries(stateVarName: String): 
Iterator[InternalRow] = {
+    if (partition.sourceOptions.flattenCollectionTypes) {
+      store
+        .iterator(stateVarName)
+        .flatMap { pair =>
+          val key = pair.key
+          val result = store.valuesIterator(key, stateVarName)
+          result.map { entry =>
+            SchemaUtil.unifyStateRowPair((key, entry), partition.partition)
+          }
+        }
+    } else {
+      store
+        .iterator(stateVarName)
+        .map { pair =>
+          val key = pair.key
+          val result = store.valuesIterator(key, stateVarName)
+          var unsafeRowArr: Seq[UnsafeRow] = Seq.empty
+          result.foreach { entry =>
+            unsafeRowArr = unsafeRowArr :+ entry.copy()
+          }

Review Comment:
   Have you considered using a mutable collection (ArrayBuffer) for 
**unsafeRowArr** to get rid of the overhead of copying? As far as I understand, 
there's no risk of race conditions here, and you also convert it to an 
immutable array before you pass it to another function, so it can't be 
unexpectedly modified outside. 
   Wdyt?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to