Github user ash211 commented on a diff in the pull request:
https://github.com/apache/spark/pull/1486#discussion_r15681195
--- Diff: core/src/main/scala/org/apache/spark/rdd/NewHadoopRDD.scala ---
@@ -157,9 +157,24 @@ class NewHadoopRDD[K, V](
new InterruptibleIterator(context, iter)
}
- override def getPreferredLocations(split: Partition): Seq[String] = {
- val theSplit = split.asInstanceOf[NewHadoopPartition]
- theSplit.serializableHadoopSplit.value.getLocations.filter(_ !=
"localhost")
+ override def getPreferredLocations(hsplit: Partition): Seq[String] = {
+ val split =
hsplit.asInstanceOf[NewHadoopPartition].serializableHadoopSplit.value
+ val locs = HadoopRDD.NEW_HADOOP_CLASSES match {
+ case Some(c) =>
+ try {
+ val infos =
c.newGetLocationInfo.invoke(split).asInstanceOf[Array[Object]]
+ Some(HadoopRDD.convertSplitLocationInfo(infos))
+ } catch {
+ case e : Exception =>
+ logInfo("Failed to use InputSplit#getLocationInfo.", e) //
WATERMELON
+ None
+ }
+ case None => None
+ }
+ locs match {
--- End diff --
locs.getOrElse(split.getLocations.filter(_ != "localhost")) is more
straightforward to my eyes. And if this is a hot codepath the slightly-slower
match syntax might be a concern
---
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.
---