You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/07 08:04:27 UTC
[GitHub] [spark] dongjoon-hyun commented on a change in pull request #33924: [SPARK-36682][CORE][TEST] Add Hadoop sequence file test for different Hadoop codecs
dongjoon-hyun commented on a change in pull request #33924:
URL: https://github.com/apache/spark/pull/33924#discussion_r703277386
##########
File path: core/src/test/scala/org/apache/spark/FileSuite.scala
##########
@@ -113,25 +113,33 @@ class FileSuite extends SparkFunSuite with LocalSparkContext {
assert(output.map(_.toString).collect().toList === List("(1,a)", "(2,aa)", "(3,aaa)"))
}
- test("SequenceFile (compressed)") {
- sc = new SparkContext("local", "test")
- val normalDir = new File(tempDir, "output_normal").getAbsolutePath
- val compressedOutputDir = new File(tempDir, "output_compressed").getAbsolutePath
- val codec = new DefaultCodec()
+ def runSequenceFileCodecTest(codec: CompressionCodec, codecName: String): Unit = {
+ test(s"SequenceFile (compressed) - $codecName") {
+ sc = new SparkContext("local", "test")
+ val normalDir = new File(tempDir, "output_normal").getAbsolutePath
+ val compressedOutputDir = new File(tempDir, "output_compressed").getAbsolutePath
- val data = sc.parallelize(Seq.fill(100)("abc"), 1).map(x => (x, x))
- data.saveAsSequenceFile(normalDir)
- data.saveAsSequenceFile(compressedOutputDir, Some(classOf[DefaultCodec]))
+ val data = sc.parallelize(Seq.fill(100)("abc"), 1).map(x => (x, x))
+ data.saveAsSequenceFile(normalDir)
+ data.saveAsSequenceFile(compressedOutputDir, Some(codec.getClass))
- val normalFile = new File(normalDir, "part-00000")
- val normalContent = sc.sequenceFile[String, String](normalDir).collect
- assert(normalContent === Array.fill(100)(("abc", "abc")))
+ val normalFile = new File(normalDir, "part-00000")
+ val normalContent = sc.sequenceFile[String, String](normalDir).collect
+ assert(normalContent === Array.fill(100)(("abc", "abc")))
- val compressedFile = new File(compressedOutputDir, "part-00000" + codec.getDefaultExtension)
- val compressedContent = sc.sequenceFile[String, String](compressedOutputDir).collect
- assert(compressedContent === Array.fill(100)(("abc", "abc")))
+ val compressedFile = new File(compressedOutputDir, "part-00000" + codec.getDefaultExtension)
+ val compressedContent = sc.sequenceFile[String, String](compressedOutputDir).collect
+ assert(compressedContent === Array.fill(100)(("abc", "abc")))
- assert(compressedFile.length < normalFile.length)
+ assert(compressedFile.length < normalFile.length)
+ }
+ }
+
+ // Hadoop "gzip" codec doesn't support sequence file yet.
+ // Hadoop "zstd" codecs needs native library installed.
+ Seq((new DefaultCodec(), "default"), (new BZip2Codec(), "bzip2"), (new GzipCodec(), "gzip"),
+ (new Lz4Codec(), "lz4"), (new SnappyCodec, "snappy")).foreach { case (codec, codecName) =>
Review comment:
Thank you for filing JIRAs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org