Skip to content

Commit

Permalink
A few comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Or committed Dec 10, 2014
1 parent f370a4e commit 3ebf8bd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/src/main/scala/org/apache/spark/rdd/CoalescedRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ private[spark] case class CoalescedRDDPartition(
*/
def localFraction: Double = {
val loc = parents.count { p =>
preferredLocation.exists { l =>
rdd.context.getPreferredLocs(rdd, p.index).map(_.host).contains(l)
}
val parentPreferredLocations = rdd.context.getPreferredLocs.map(_.host)
preferredLocation.exists(parentPreferredLocations.contains)
}
if (parents.size == 0) 0.0 else (loc.toDouble / parents.size.toDouble)
}
Expand Down Expand Up @@ -348,5 +347,8 @@ private case class PartitionGroup(prefLoc: Option[String] = None) {
}

private object PartitionGroup {
def apply(prefLoc: String): PartitionGroup = PartitionGroup(Some(prefLoc))
def apply(prefLoc: String): PartitionGroup = {
require(prefLoc != "", "Preferred location must not be empty")
PartitionGroup(Some(prefLoc))
}
}

0 comments on commit 3ebf8bd

Please sign in to comment.