Github user markhamstra commented on a diff in the pull request: https://github.com/apache/spark/pull/140#discussion_r10618038 --- Diff: core/src/main/scala/org/apache/spark/rdd/DoubleRDDFunctions.scala --- @@ -86,14 +92,9 @@ class DoubleRDDFunctions(self: RDD[Double]) extends Logging with Serializable { * If the elements in RDD do not vary (max == min) always returns a single bucket. */ def histogram(bucketCount: Int): Pair[Array[Double], Array[Long]] = { - // Compute the minimum and the maxium - val (max: Double, min: Double) = self.mapPartitions { items => - Iterator(items.foldRight(Double.NegativeInfinity, - Double.PositiveInfinity)((e: Double, x: Pair[Double, Double]) => - (x._1.max(e), x._2.min(e)))) - }.reduce { (maxmin1, maxmin2) => - (maxmin1._1.max(maxmin2._1), maxmin1._2.min(maxmin2._2)) - } + // Compute the minimum and the maximum from stats once + val _stats = stats() + val (max: Double, min: Double) = (_stats.max, _stats.min) --- End diff -- Minor, but I'd prefer not to unnecessarily bind a val in a scope where it doesn't need to be used: ```scala // Compute the minimum and the maximum from stats once val (max, min) = { val sc = stats(); (sc.max, sc.min) } ```
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---