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/03/06 13:16:33 UTC

[GitHub] [spark] srowen commented on a change in pull request #23986: [SPARK-27070] Fix performance bug in DefaultPartitionCoalescer

srowen commented on a change in pull request #23986: [SPARK-27070] Fix performance bug in DefaultPartitionCoalescer
URL: https://github.com/apache/spark/pull/23986#discussion_r262932060
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/rdd/CoalescedRDD.scala
 ##########
 @@ -156,9 +156,11 @@ private[spark] class CoalescedRDD[T: ClassTag](
 
 private class DefaultPartitionCoalescer(val balanceSlack: Double = 0.10)
   extends PartitionCoalescer {
-  def compare(o1: PartitionGroup, o2: PartitionGroup): Boolean = o1.numPartitions < o2.numPartitions
-  def compare(o1: Option[PartitionGroup], o2: Option[PartitionGroup]): Boolean =
-    if (o1 == None) false else if (o2 == None) true else compare(o1.get, o2.get)
+
+  implicit val partitionGroupOrdering: Ordering[PartitionGroup]
+  = (o1: PartitionGroup, o2: PartitionGroup)
+  => o1.numPartitions - o2.numPartitions
 
 Review comment:
   The indent is off here. Returning the result of a subtraction in compare can overflow, though I don't think it can happen in practice here. Still, see below, I think we can just remove this.

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