tgravescs commented on a change in pull request #25264: 
[SPARK-28213][SQL][followup] code cleanup and bug fix for columnar execution 
framework
URL: https://github.com/apache/spark/pull/25264#discussion_r309713861
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala
 ##########
 @@ -334,37 +334,63 @@ case class FileSourceScanExec(
     inputRDD :: Nil
   }
 
-  override lazy val metrics =
-    Map("numOutputRows" -> SQLMetrics.createMetric(sparkContext, "number of 
output rows"),
-      "numFiles" -> SQLMetrics.createMetric(sparkContext, "number of files 
read"),
-      "metadataTime" -> SQLMetrics.createTimingMetric(sparkContext, "metadata 
time"),
-      "scanTime" -> SQLMetrics.createTimingMetric(sparkContext, "scan time"))
+  override lazy val metrics = Map(
+    "numOutputRows" -> SQLMetrics.createMetric(sparkContext, "number of output 
rows"),
+    "numFiles" -> SQLMetrics.createMetric(sparkContext, "number of files 
read"),
+    "metadataTime" -> SQLMetrics.createTimingMetric(sparkContext, "metadata 
time"),
+    "scanTime" -> SQLMetrics.createTimingMetric(sparkContext, "scan time"))
+
+  private abstract class ScanTimeTrackingIterator[T](
+      fileScanIterator: Iterator[T],
+      scanTimeMetrics: SQLMetric) extends Iterator[T] {
+
+    override def hasNext: Boolean = {
+      // The `FileScanRDD` returns an iterator which scans the file during the 
`hasNext` call.
+      val startNs = System.nanoTime()
+      val re = fileScanIterator.hasNext
+      scanTimeMetrics += ((System.nanoTime() - startNs) / (1000 * 1000))
 
 Review comment:
   NANOSECONDS.toMillis 

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

Reply via email to