Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/423#discussion_r11920691
--- Diff: core/src/test/java/org/apache/spark/JavaAPISuite.java ---
@@ -182,13 +182,30 @@ 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> dataArray = Arrays.asList(1, 2, 3, 4);
+ JavaPairRDD<Integer, Long> zip =
sc.parallelize(dataArray).zipWithUniqueId();
+ JavaRDD<Long> indexes = zip.values();
+ Assert.assertTrue(new HashSet<Long>(indexes.collect()).size() == 4);
+ }
+
+ @Test
+ public void zipWithIndex() {
+ List<Integer> dataArray = Arrays.asList(1, 2, 3, 4);
+ JavaPairRDD<Integer, Long> zip =
sc.parallelize(dataArray).zipWithIndex();
+ JavaRDD<Long> indexes = zip.values();
+ HashSet<Long> correctIndexes = new HashSet<Long>(Arrays.asList(0l, 1l,
2l, 3l));
--- End diff --
You should use a list instead of a set here, because you want to assert on
the exact order.
Also, use `L` instead of `l`.
---
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.
---