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/08/01 14:03:52 UTC

[GitHub] [spark] tgravescs commented on a change in pull request #25264: [SPARK-28213][SQL][followup] code cleanup and bug fix for columnar execution framework

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