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

    https://github.com/apache/spark/pull/916#discussion_r13691100
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
    @@ -394,20 +402,22 @@ abstract class RDD[T: ClassTag](
           return new Array[T](0)
         }
     
    -    if (initialCount > Integer.MAX_VALUE - 1) {
    -      maxSelected = Integer.MAX_VALUE - 1
    -    } else {
    -      maxSelected = initialCount.toInt
    +    if (!withReplacement && num > initialCount) {
    +      throw new IllegalArgumentException("Cannot create sample larger than 
the original when " +
    +        "sampling without replacement")
         }
     
    -    if (num > initialCount && !withReplacement) {
    -      total = maxSelected
    -      fraction = multiplier * (maxSelected + 1) / initialCount
    -    } else {
    -      fraction = multiplier * (num + 1) / initialCount
    -      total = num
    +    if (initialCount > Int.MaxValue - 1) {
    +      val maxSelected = Int.MaxValue - (numStDev * 
math.sqrt(Int.MaxValue)).toInt
    --- End diff --
    
    `maxSelected` -> `maxSampleSize`? Because we haven't selected any yet.


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

Reply via email to