Github user FRosner commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5148#discussion_r27209470
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/DoubleRDDFunctions.scala 
---
    @@ -191,25 +191,22 @@ class DoubleRDDFunctions(self: RDD[Double]) extends 
Logging with Serializable {
           }
         }
         // Determine the bucket function in constant time. Requires that 
buckets are evenly spaced
    -    def fastBucketFunction(min: Double, increment: Double, count: Int)(e: 
Double): Option[Int] = {
    +    def fastBucketFunction(min: Double, max: Double, count: Int)(e: 
Double): Option[Int] = {
           // If our input is not a number unless the increment is also NaN 
then we fail fast
    -      if (e.isNaN()) {
    -        return None
    -      }
    -      val bucketNumber = (e - min)/(increment)
    -      // We do this rather than buckets.lengthCompare(bucketNumber)
    -      // because Array[Double] fails to override it (for now).
    -      if (bucketNumber > count || bucketNumber < 0) {
    +      if (e.isNaN || e < min || e > max) {
             None
           } else {
    -        Some(bucketNumber.toInt.min(count - 1))
    +        val bucketNumber = (((e - min) / (max - min)) * count).toInt
    --- End diff --
    
    Agreed!


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to