From 892fe600e48b49b26a29120c99d171db02c659ab Mon Sep 17 00:00:00 2001 From: Xin Ren Date: Mon, 21 Mar 2016 18:19:29 -0700 Subject: [PATCH] [SPARK-13019] fix arguments passing for 2.10 --- .../spark/examples/mllib/StratifiedSamplingExample.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/src/main/scala/org/apache/spark/examples/mllib/StratifiedSamplingExample.scala b/examples/src/main/scala/org/apache/spark/examples/mllib/StratifiedSamplingExample.scala index 169467926ce46..e100cf09c6391 100644 --- a/examples/src/main/scala/org/apache/spark/examples/mllib/StratifiedSamplingExample.scala +++ b/examples/src/main/scala/org/apache/spark/examples/mllib/StratifiedSamplingExample.scala @@ -19,6 +19,7 @@ package org.apache.spark.examples.mllib import org.apache.spark.{SparkConf, SparkContext} +import org.apache.spark.util.Utils object StratifiedSamplingExample { @@ -34,11 +35,12 @@ object StratifiedSamplingExample { // specify the exact fraction desired from each key val fractions = Map(1 -> 0.1, 2 -> 0.6, 3 -> 0.3) + val seed = Utils.random.nextLong // Get an approximate sample from each stratum - val approxSample = data.sampleByKey(withReplacement = false, fractions) + val approxSample = data.sampleByKey(withReplacement = false, fractions = fractions, seed) // Get an exact sample from each stratum - val exactSample = data.sampleByKeyExact(withReplacement = false, fractions) + val exactSample = data.sampleByKeyExact(withReplacement = false, fractions = fractions, seed) // $example off$ println("approxSample size is " + approxSample.collect().size.toString)