You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/26 01:51:11 UTC

[GitHub] [spark] viirya commented on a change in pull request #24696: [SPARK-27832][SQL] Don't decompress and create column batch when the task is completed

viirya commented on a change in pull request #24696: [SPARK-27832][SQL] Don't decompress and create column batch when the task is completed
URL: https://github.com/apache/spark/pull/24696#discussion_r287579319
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/columnar/InMemoryTableScanExec.scala
 ##########
 @@ -98,14 +98,23 @@ case class InMemoryTableScanExec(
     val columnarBatch = new ColumnarBatch(columnVectors.asInstanceOf[Array[ColumnVector]])
     columnarBatch.setNumRows(rowCount)
 
-    for (i <- attributes.indices) {
-      ColumnAccessor.decompress(
-        cachedColumnarBatch.buffers(columnIndices(i)),
-        columnarBatch.column(i).asInstanceOf[WritableColumnVector],
-        columnarBatchSchema.fields(i).dataType, rowCount)
+    // Decompress cached batch if the task is not completed, or there is no task context.
+    if (taskContext.isEmpty || !taskContext.get.isCompleted) {
+      for (i <- attributes.indices) {
+        ColumnAccessor.decompress(
+          cachedColumnarBatch.buffers(columnIndices(i)),
+          columnarBatch.column(i).asInstanceOf[WritableColumnVector],
+          columnarBatchSchema.fields(i).dataType, rowCount)
+      }
+    }
+    // When the task is already completed, it is not valid to access a closed batch.
+    if (taskContext.nonEmpty && taskContext.get.isCompleted) {
+      columnarBatch.close()
 
 Review comment:
   Yea.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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