spark 加载多个目录; RDD输出到hdfs文件压缩

来源:互联网 发布:html 炫酷展示页源码 编辑:程序博客网 时间:2024/06/05 04:56

(1)  spark textFile加载多个目录:

  其实很简单,将多个目录(对应多个字符串),用,作为分隔符连接起来

   val inputPath = List("hdfs://localhost:9000/test/hiveTest", "hdfs://localhost:9000/test/hiveTest2")
                    .mkString(",")

  sparkContext
      .textFile( inputPath )


(2) spark  rdd  saveAsTextFile 输出到HDFS 文件压缩


    rdd.saveAsTextFile( "hdfs://localhost:9000/test/out" ) //正常不压缩


    rdd.saveAsTextFile( "hdfs://localhost:9000/test/outGzip", classOf[ GzipCodec ] )    //Gzip压缩输出


    rdd.saveAsTextFile( "hdfs://localhost:9000/test/outBzip2", classOf[ BZip2Codec ] )  //bzip2 压缩输出


  hadoop 文件压缩格式对比:http://www.echojb.com/web-application-server/2017/07/10/449381.html




阅读全文
0 0