Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/13260#discussion_r64338520
--- 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
}
- Utils.randomizeInPlace(samples, rand).take(num)
+ Utils.randomizeInPlace(samples.collect(), rand).take(num)
--- End diff --
Indeed, I agree with you. This PR tried to improve stability, but there is
a regression on most common cases. I missed that. I'll close this PR.
Thank you for spending your precious time on this PR and sorry for closing
this, @andrewor14 and @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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]