cloud-fan commented on a change in pull request #34575:
URL: https://github.com/apache/spark/pull/34575#discussion_r772209636



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileScanRDD.scala
##########
@@ -103,6 +116,108 @@ class FileScanRDD(
         context.killTaskIfInterrupted()
         (currentIterator != null && currentIterator.hasNext) || nextIterator()
       }
+
+      ///////////////////////////
+      // FILE METADATA METHODS //
+      ///////////////////////////
+
+      // metadata columns unsafe row, will only be updated when the current 
file is changed
+      @volatile private var metadataColumnsUnsafeRow: UnsafeRow = _
+      // metadata columns internal row, will only be updated when the current 
file is changed
+      @volatile private var metadataColumnsInternalRow: InternalRow = _
+      // an unsafe joiner to join an unsafe row with the metadata unsafe row
+      lazy private val metadataUnsafeRowJoiner =
+        GenerateUnsafeRowJoiner.create(requiredSchema, 
metadataColumns.toStructType)
+      // metadata columns unsafe row converter
+      lazy private val unsafeRowConverter = {
+        val metadataColumnsDataTypes = metadataColumns.map(_.dataType).toArray
+        val converter = UnsafeProjection.create(metadataColumnsDataTypes)
+        (row: InternalRow) => converter(row)
+      }
+
+      /**
+       * For each partitioned file, metadata columns for each record in the 
file are exactly same.
+       * Only update metadata columns when `currentFile` is changed.
+       */
+      private def updateMetadataColumns(): Unit = {
+        if (metadataColumns.nonEmpty) {
+          if (currentFile == null) {
+            metadataColumnsUnsafeRow = null
+            metadataColumnsInternalRow = null
+          } else {
+            // construct an internal row
+            val path = new Path(currentFile.filePath)

Review comment:
       ```suggestion
               val path = new Path(currentFile.filePath).toString
   ```
   




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to