Skip to content

Commit 892fe60

Browse files
committed
[SPARK-13019] fix arguments passing for 2.10
1 parent fd6d786 commit 892fe60

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/src/main/scala/org/apache/spark/examples/mllib/StratifiedSamplingExample.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.spark.examples.mllib
2020

2121
import org.apache.spark.{SparkConf, SparkContext}
22+
import org.apache.spark.util.Utils
2223

2324
object StratifiedSamplingExample {
2425

@@ -34,11 +35,12 @@ object StratifiedSamplingExample {
3435

3536
// specify the exact fraction desired from each key
3637
val fractions = Map(1 -> 0.1, 2 -> 0.6, 3 -> 0.3)
38+
val seed = Utils.random.nextLong
3739

3840
// Get an approximate sample from each stratum
39-
val approxSample = data.sampleByKey(withReplacement = false, fractions)
41+
val approxSample = data.sampleByKey(withReplacement = false, fractions = fractions, seed)
4042
// Get an exact sample from each stratum
41-
val exactSample = data.sampleByKeyExact(withReplacement = false, fractions)
43+
val exactSample = data.sampleByKeyExact(withReplacement = false, fractions = fractions, seed)
4244
// $example off$
4345

4446
println("approxSample size is " + approxSample.collect().size.toString)

0 commit comments

Comments
 (0)