Repository: incubator-spark
Updated Branches:
  refs/heads/master 73cfdcfe7 -> 5af4477c2


Add subtractByKey to the JavaPairRDD wrapper

Author: Punya Biswal <pbis...@palantir.com>

Closes #600 from punya/subtractByKey-java and squashes the following commits:

e961913 [Punya Biswal] Hide implicit ClassTags from Java API
c5d317b [Punya Biswal] Add subtractByKey to the JavaPairRDD wrapper


Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/5af4477c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/5af4477c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/5af4477c

Branch: refs/heads/master
Commit: 5af4477c2b191f1ffd9814192d7017e85cf95191
Parents: 73cfdcf
Author: Punya Biswal <pbis...@palantir.com>
Authored: Sun Feb 16 18:55:59 2014 -0800
Committer: Aaron Davidson <aa...@databricks.com>
Committed: Sun Feb 16 18:55:59 2014 -0800

----------------------------------------------------------------------
 .../org/apache/spark/api/java/JavaPairRDD.scala | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/5af4477c/core/src/main/scala/org/apache/spark/api/java/JavaPairRDD.scala
----------------------------------------------------------------------
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 5b1bf94..cd0aea0 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
@@ -278,6 +278,29 @@ class JavaPairRDD[K, V](val rdd: RDD[(K, V)])(implicit val 
kClassTag: ClassTag[K
     fromRDD(rdd.subtract(other, p))
 
   /**
+   * Return an RDD with the pairs from `this` whose keys are not in `other`.
+   *
+   * Uses `this` partitioner/partition size, because even if `other` is huge, 
the resulting
+   * RDD will be <= us.
+   */
+  def subtractByKey[W](other: JavaPairRDD[K, W]): JavaPairRDD[K, V] = {
+    implicit val cmw: ClassTag[W] = 
implicitly[ClassTag[AnyRef]].asInstanceOf[ClassTag[W]]
+    fromRDD(rdd.subtractByKey(other))
+  }
+
+  /** Return an RDD with the pairs from `this` whose keys are not in `other`. 
*/
+  def subtractByKey[W](other: JavaPairRDD[K, W], numPartitions: Int): 
JavaPairRDD[K, V] = {
+    implicit val cmw: ClassTag[W] = 
implicitly[ClassTag[AnyRef]].asInstanceOf[ClassTag[W]]
+    fromRDD(rdd.subtractByKey(other, numPartitions))
+  }
+
+  /** Return an RDD with the pairs from `this` whose keys are not in `other`. 
*/
+  def subtractByKey[W](other: JavaPairRDD[K, W], p: Partitioner): 
JavaPairRDD[K, V] = {
+    implicit val cmw: ClassTag[W] = 
implicitly[ClassTag[AnyRef]].asInstanceOf[ClassTag[W]]
+    fromRDD(rdd.subtractByKey(other, p))
+  }
+
+  /**
    * Return a copy of the RDD partitioned using the specified partitioner.
    */
   def partitionBy(partitioner: Partitioner): JavaPairRDD[K, V] =

Reply via email to