Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uncleGen committed Nov 30, 2015
1 parent bb2ed41 commit 3cafda5
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ private[spark] object SamplingUtils {
val rand = new XORShiftRandom(seed)
while (input.hasNext) {
val item = input.next()
val replacementIndex = if (l < Int.MaxValue) {
rand.nextInt(l.toInt)
} else {
rand.nextLong()
}
val replacementIndex = (rand.nextDouble() * l).toLong
if (replacementIndex < k) {
reservoir(replacementIndex.toInt) = item
}
Expand Down

0 comments on commit 3cafda5

Please sign in to comment.