2016-04-26 51 views
2

我成功读取S3中存储的文本文件,并使用Spark数据框以ORC格式将其写回到S3。 - inputDf.write().orc(outputPath);
我无法做的是转换为快速压缩的ORC格式。我已经试着在设置编解码器的时候给出选项,但Spark仍然是作为正常的ORC编写的。如何使用Spark Dataframes实现使用Snappy压缩到S3的ORC格式书写?使用Snappy压缩以ORC格式写入Spark数据帧

+0

见https://issues.apache.org/jira/browse/SPARK-13​​543 –

+0

默认(zlib的)可能比斯纳皮更好反正:https://community.hortonworks.com/questions/4067 /snappy-vs-zlib-pros-and-cons-for-each-compression.html –

+0

@MarkRajcok谢谢,这意味着我只能在使用Spark 2.0时使用.option压缩ORC格式。 有没有其他方法可以建议我可以在哪里压缩输出。我正在使用Spark 1.6的亚马逊EMR – Karshit

回答

1

对于任何面临同样问题的人,在Spark 2.0中, 默认是可能的。 ORC的默认压缩格式设置为snappy。

public class ConvertToOrc { 
    public static void main(String[] args) { 
     SparkSession spark = SparkSession 
       .builder() 
       .appName("OrcConvert") 
       .getOrCreate(); 
     String inputPath = args[0]; 
     String outputPath = args[1]; 

     Dataset<Row> inputDf = spark.read().option("sep", "\001").option("quote", "'").csv(inputPath); 
     inputDf.write().format("orc").save(outputPath); 

    } 
} 
+1

真的很想知道如何更改ORC的默认压缩... – Azuaron