dongjoon-hyun 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_r287577216
##########
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:
So, does this for the case when `addTaskCompletionListener` is not called
yet?
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]