Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13260#discussion_r64337410
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
    @@ -550,17 +550,19 @@ abstract class RDD[T: ClassTag](
             } else {
               val fraction = SamplingUtils.computeFractionForSampleSize(num, 
initialCount,
                 withReplacement)
    -          var samples = this.sample(withReplacement, fraction, 
rand.nextInt()).collect()
    +          var samples = this.sample(withReplacement, fraction, 
rand.nextInt())
    +          var count = samples.count()
     
               // If the first sample didn't turn out large enough, keep trying 
to take samples;
               // this shouldn't happen often because we use a big multiplier 
for the initial size
               var numIters = 0
    -          while (samples.length < num) {
    +          while (count < num) {
                 logWarning(s"Needed to re-sample due to insufficient sample 
size. Repeat #$numIters")
    -            samples = this.sample(withReplacement, fraction, 
rand.nextInt()).collect()
    +            samples = this.sample(withReplacement, fraction, 
rand.nextInt())
    +            count = samples.count()
                 numIters += 1
    --- End diff --
    
    Thank you, @hvanhovell !


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to