Skip to content

Commit

Permalink
modify some pointless and verbose code
Browse files Browse the repository at this point in the history
  • Loading branch information
uncleGen committed Nov 28, 2015
1 parent 986fa5c commit bb2ed41
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ private[spark] object SamplingUtils {
val rand = new XORShiftRandom(seed)
while (input.hasNext) {
val item = input.next()
val replacementIndex = l < Int.MaxValue match {
case true => rand.nextInt(l.toInt)
case false => rand.nextInt()
val replacementIndex = if (l < Int.MaxValue) {
rand.nextInt(l.toInt)
} else {
rand.nextLong()
}
if (replacementIndex < k) {
reservoir(replacementIndex) = item
reservoir(replacementIndex.toInt) = item
}
l += 1
}
Expand Down

0 comments on commit bb2ed41

Please sign in to comment.