Github user sryza commented on a diff in the pull request:
https://github.com/apache/spark/pull/2087#discussion_r19387877
--- Diff: core/src/main/scala/org/apache/spark/rdd/HadoopRDD.scala ---
@@ -224,18 +223,18 @@ class HadoopRDD[K, V](
val key: K = reader.createKey()
val value: V = reader.createValue()
- // Set the task input metrics.
val inputMetrics = new InputMetrics(DataReadMethod.Hadoop)
- try {
- /* bytesRead may not exactly equal the bytes read by a task: split
boundaries aren't
- * always at record boundaries, so tasks may need to read into
other splits to complete
- * a record. */
- inputMetrics.bytesRead = split.inputSplit.value.getLength()
- } catch {
- case e: java.io.IOException =>
- logWarning("Unable to get input size to set InputMetrics for
task", e)
+ // Find a function that will return the FileSystem bytes read by
this thread.
+ val bytesReadCallback = if
(split.inputSplit.value.isInstanceOf[FileSplit]) {
+ SparkHadoopUtil.get.getFSBytesReadOnThreadCallback(
+ split.inputSplit.value.asInstanceOf[FileSplit].getPath, jobConf)
+ } else {
+ None
+ }
+ if (bytesReadCallback.isDefined) {
+ context.taskMetrics.inputMetrics = Some(inputMetrics)
}
- context.taskMetrics.inputMetrics = Some(inputMetrics)
--- End diff --
My thinking was that, if we aren't able to get the in-progress metrics
callback, we don't want to set the InputMetrics until the end of the task. If
we were to set the input metrics at the beginning of the task, in-progress
metrics would always show its bytes read as 0, instead of not at all, which is
confusing.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]