Spark: saveAsTextFile without compression

后端 未结 1 1091
生来不讨喜
生来不讨喜 2021-02-13 23:21

By default, newer versions of Spark use compression when saving text files. For example:

val txt = sc.parallelize(List(\"Hello\", \"world\", \"!\"))
txt.saveAsT         


        
1条回答
  •  一生所求
    2021-02-14 00:21

    I can see the text file in HDFS without any compression with this code.

    val conf = new SparkConf().setMaster("local").setAppName("App name")
    val sc = new SparkContext(conf);
    sc.hadoopConfiguration.set("mapred.output.compress", "false")
    val txt = sc.parallelize(List("Hello", "world", "!"))
    txt.saveAsTextFile("hdfs/path/to/save/file")
    

    You can set all Hadoop related properties to hadoopConfiguration on sc.

    Verified this code in Spark 1.5.2(scala 2.11).

    0 讨论(0)
提交回复
热议问题