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

    https://github.com/apache/spark/pull/423#discussion_r11870757
  
    --- Diff: core/src/test/java/org/apache/spark/JavaAPISuite.java ---
    @@ -182,13 +182,39 @@ public void call(String s) {
         Assert.assertEquals(2, foreachCalls);
       }
     
    -    @Test
    -    public void toLocalIterator() {
    -        List<Integer> correct = Arrays.asList(1, 2, 3, 4);
    -        JavaRDD<Integer> rdd = sc.parallelize(correct);
    -        List<Integer> result = Lists.newArrayList(rdd.toLocalIterator());
    -        Assert.assertTrue(correct.equals(result));
    -    }
    +  @Test
    +  public void toLocalIterator() {
    +    List<Integer> correct = Arrays.asList(1, 2, 3, 4);
    +    JavaRDD<Integer> rdd = sc.parallelize(correct);
    +    List<Integer> result = Lists.newArrayList(rdd.toLocalIterator());
    +    Assert.assertTrue(correct.equals(result));
    +  }
    +
    +  @Test
    +  public void zipWithUniqueId() {
    +    List<Integer> correct = Arrays.asList(1, 2, 3, 4);
    +    JavaPairRDD<Integer, Long> zip = 
sc.parallelize(correct).zipWithUniqueId();
    +    JavaRDD<Long> indexes = zip.map(new Function<Tuple2<Integer, Long>, 
Long>() {
    +      @Override
    +      public Long call(Tuple2<Integer, Long> t) throws Exception {
    +        return t._2();
    +      }
    +    });
    +    Assert.assertTrue(new HashSet<Long>(indexes.collect()).size() == 4);
    +  }
    +
    +  @Test
    +  public void zipWithIndex() {
    +    List<Integer> correct = Arrays.asList(1, 2, 3, 4);
    +    JavaPairRDD<Integer, Long> zip = 
sc.parallelize(correct).zipWithIndex();
    +    JavaRDD<Long> indexes = zip.map(new Function<Tuple2<Integer, Long>, 
Long>() {
    +      @Override
    +      public Long call(Tuple2<Integer, Long> t) throws Exception {
    +        return t._2();
    +      }
    +    });
    +    Assert.assertTrue(new HashSet<Long>(indexes.collect()).size() == 4);
    --- End diff --
    
    Should assert the indices are exactly (0, 1, 2, 3).


---
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.
---

Reply via email to