Github user mateiz commented on a diff in the pull request:
https://github.com/apache/spark/pull/1658#discussion_r17707533
--- Diff: core/src/test/java/org/apache/spark/JavaAPISuite.java ---
@@ -836,6 +838,29 @@ public void sequenceFile() {
Assert.assertEquals(pairs, readRDD.collect());
}
+ @Test
+ public void binaryFiles() throws Exception {
+ // Reusing the wholeText files example
+ byte[] content1 = "spark is easy to use.\n".getBytes("utf-8");
+
+
+ String tempDirName = tempDir.getAbsolutePath();
+ File file1 = new File(tempDirName + "/part-00000");
+
+ FileOutputStream fos1 = new FileOutputStream(file1);
+
+ FileChannel channel1 = fos1.getChannel();
+ ByteBuffer bbuf = java.nio.ByteBuffer.wrap(content1);
+ channel1.write(bbuf);
+
+
+ JavaPairRDD<String, byte[]> readRDD =
sc.binaryFiles(tempDirName,3);
+ List<Tuple2<String, byte[]>> result = readRDD.collect();
+ for (Tuple2<String, byte[]> res : result) {
+ Assert.assertArrayEquals(content1, res._2());
+ }
+ }
--- End diff --
Make sure to add tests for the new methods too (binaryRecords and data
streams). For data streams, add a test where we cache them and go over some RDD
multiple times, to make sure they can be re-read.
---
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]