Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3327#discussion_r21341919
  
    --- Diff: core/src/test/java/org/apache/spark/JavaAPISuite.java ---
    @@ -322,6 +322,42 @@ public Boolean call(Integer x) {
         Assert.assertEquals(2, 
Iterables.size(oddsAndEvens.lookup(true).get(0)));  // Evens
         Assert.assertEquals(5, 
Iterables.size(oddsAndEvens.lookup(false).get(0))); // Odds
       }
    +   
    +   @Test
    +  public void groupByOnPairRDD() {
    +    JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 1, 2, 3, 5, 8, 
13));
    +    Function<scala.Tuple2<Integer, Integer>, Boolean> areOdd = new 
Function<scala.Tuple2<Integer, Integer>, Boolean>() {
    +      @Override
    +      public Boolean call(scala.Tuple2<Integer, Integer> x) {
    +        return x._1 % 2 == 0 && x._2 % 2 == 0;
    +      }
    +    };
    +           JavaPairRDD<Integer, Integer> pairrdd = rdd.zip(rdd);
    +    JavaPairRDD<Boolean, Iterable<scala.Tuple2<Integer, Integer>>> 
oddsAndEvens = pairrdd.groupBy(areOdd);
    +    Assert.assertEquals(2, oddsAndEvens.count());
    +    Assert.assertEquals(2, 
Iterables.size(oddsAndEvens.lookup(true).get(0)));  // Evens
    +    Assert.assertEquals(5, 
Iterables.size(oddsAndEvens.lookup(false).get(0))); // Odds
    +
    +    oddsAndEvens = pairrdd.groupBy(areOdd, 1);
    +    Assert.assertEquals(2, oddsAndEvens.count());
    +    Assert.assertEquals(2, 
Iterables.size(oddsAndEvens.lookup(true).get(0)));  // Evens
    +    Assert.assertEquals(5, 
Iterables.size(oddsAndEvens.lookup(false).get(0))); // Odds
    +  }
    +   
    +   @Test
    +  public void keyByOnPairRDD() {
    +    JavaRDD<Integer> rdd = sc.parallelize(Arrays.asList(1, 1, 2, 3, 5, 8, 
13));
    +    Function<scala.Tuple2<Integer, Integer>, String> areOdd = new 
Function<scala.Tuple2<Integer, Integer>, String>() {
    +      @Override
    +      public String call(scala.Tuple2<Integer, Integer> x) {
    +        return ""+(x._1 +x._2);
    --- End diff --
    
    The spacing here is messy.  Also, `"" + x` is messy; just do `x.toString()` 
instead if you want to convert an object in a string.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to