aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/org/apache
diff options
context:
space:
mode:
authorSean Owen <sowen@cloudera.com>2016-04-23 10:47:50 -0700
committerReynold Xin <rxin@databricks.com>2016-04-23 10:47:50 -0700
commitbe0d5d3bbebf0912c27bf41ce27b5ba214e61e19 (patch)
tree3d067a6e3aeb441217475e8fabcb4d6131575e61 /core/src/main/scala/org/apache
parenta55fbe2a16aa0866ff8aca25bf9f772e6eb516a1 (diff)
downloadspark-be0d5d3bbebf0912c27bf41ce27b5ba214e61e19.tar.gz
spark-be0d5d3bbebf0912c27bf41ce27b5ba214e61e19.tar.bz2
spark-be0d5d3bbebf0912c27bf41ce27b5ba214e61e19.zip
[SPARK-14873][CORE] Java sampleByKey methods take ju.Map but with Scala Double values; results in type Object
## What changes were proposed in this pull request? Java `sampleByKey` methods should accept `Map` with `java.lang.Double` values ## How was this patch tested? Existing (updated) Jenkins tests Author: Sean Owen <sowen@cloudera.com> Closes #12637 from srowen/SPARK-14873.
Diffstat (limited to 'core/src/main/scala/org/apache')
-rw-r--r--core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala18
1 files changed, 12 insertions, 6 deletions
diff --git a/core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala b/core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
index 2897272a8b..1c95bc4bfc 100644
--- a/core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
+++ b/core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
@@ -139,9 +139,12 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])
* math.ceil(numItems * samplingRate) over all key values.
*/
def sampleByKey(withReplacement: Boolean,
- fractions: java.util.Map[K, Double],
+ fractions: java.util.Map[K, jl.Double],
seed: Long): JavaPairRDD[K, V] =
- new JavaPairRDD[K, V](rdd.sampleByKey(withReplacement, fractions.asScala, seed))
+ new JavaPairRDD[K, V](rdd.sampleByKey(
+ withReplacement,
+ fractions.asScala.mapValues(_.toDouble).toMap, // map to Scala Double; toMap to serialize
+ seed))
/**
* Return a subset of this RDD sampled by key (via stratified sampling).
@@ -154,7 +157,7 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])
* Use Utils.random.nextLong as the default seed for the random number generator.
*/
def sampleByKey(withReplacement: Boolean,
- fractions: java.util.Map[K, Double]): JavaPairRDD[K, V] =
+ fractions: java.util.Map[K, jl.Double]): JavaPairRDD[K, V] =
sampleByKey(withReplacement, fractions, Utils.random.nextLong)
/**
@@ -168,9 +171,12 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])
* two additional passes.
*/
def sampleByKeyExact(withReplacement: Boolean,
- fractions: java.util.Map[K, Double],
+ fractions: java.util.Map[K, jl.Double],
seed: Long): JavaPairRDD[K, V] =
- new JavaPairRDD[K, V](rdd.sampleByKeyExact(withReplacement, fractions.asScala, seed))
+ new JavaPairRDD[K, V](rdd.sampleByKeyExact(
+ withReplacement,
+ fractions.asScala.mapValues(_.toDouble).toMap, // map to Scala Double; toMap to serialize
+ seed))
/**
* Return a subset of this RDD sampled by key (via stratified sampling) containing exactly
@@ -186,7 +192,7 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])
*/
def sampleByKeyExact(
withReplacement: Boolean,
- fractions: java.util.Map[K, Double]): JavaPairRDD[K, V] =
+ fractions: java.util.Map[K, jl.Double]): JavaPairRDD[K, V] =
sampleByKeyExact(withReplacement, fractions, Utils.random.nextLong)
/**