We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 986fa5c commit bb2ed41Copy full SHA for bb2ed41
core/src/main/scala/org/apache/spark/util/random/SamplingUtils.scala
@@ -56,12 +56,13 @@ private[spark] object SamplingUtils {
56
val rand = new XORShiftRandom(seed)
57
while (input.hasNext) {
58
val item = input.next()
59
- val replacementIndex = l < Int.MaxValue match {
60
- case true => rand.nextInt(l.toInt)
61
- case false => rand.nextInt()
+ val replacementIndex = if (l < Int.MaxValue) {
+ rand.nextInt(l.toInt)
+ } else {
62
+ rand.nextLong()
63
}
64
if (replacementIndex < k) {
- reservoir(replacementIndex) = item
65
+ reservoir(replacementIndex.toInt) = item
66
67
l += 1
68
0 commit comments