Skip to content

Commit

Permalink
[SPARK-13019] fix arguments passing for 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
keypointt committed Mar 22, 2016
1 parent fd6d786 commit 892fe60
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.spark.examples.mllib

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.util.Utils

object StratifiedSamplingExample {

Expand All @@ -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)
Expand Down

0 comments on commit 892fe60

Please sign in to comment.