Github user mridulm commented on a diff in the pull request:
https://github.com/apache/spark/pull/1486#discussion_r15725601
--- Diff: core/src/main/scala/org/apache/spark/rdd/HadoopRDD.scala ---
@@ -243,10 +244,23 @@ class HadoopRDD[K, V](
new HadoopMapPartitionsWithSplitRDD(this, f, preservesPartitioning)
}
- override def getPreferredLocations(split: Partition): Seq[String] = {
- // TODO: Filtering out "localhost" in case of file:// URLs
- val hadoopSplit = split.asInstanceOf[HadoopPartition]
- hadoopSplit.inputSplit.value.getLocations.filter(_ != "localhost")
+ override def getPreferredLocations(hsplit: Partition): Seq[String] = {
+ val split = hsplit.asInstanceOf[HadoopPartition].inputSplit.value
+ val locs = HadoopRDD.NEW_HADOOP_CLASSES match {
+ case Some(c) =>
+ try {
+ val lsplit = c.inputSplitWithLocationInfo.cast(split)
+ val infos = c.getLocationInfo.
+ invoke(lsplit).asInstanceOf[Array[Object]]
+ Some(HadoopRDD.convertSplitLocationInfo(infos))
--- End diff --
Given how frequently this is invoked, instead of using reflection, it is
better to have an interface and an specific impl to handle this case (where the
new hadoop api's are inlined, and not accessed via reflection).
Ofcourse, initialization to use this new impl or None would be based on
existance of the methods : and so decided via reflection - but that would be a
one time operation (replacing NEW_HADOOP_CLASSES)
---
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.
---