我正在使用Spark 1.6(Cloudera 5.8.2)並嘗試下面的方法來配置ORC屬性。但它不影響輸出。無法在Spark中配置ORC屬性
下面是我試過的代碼片段。
DataFrame dataframe =
hiveContext.createDataFrame(rowData, schema);
dataframe.write().format("orc").options(new HashMap(){
{
put("orc.compress","SNAPPY");
put("hive.exec.orc.default.compress","SNAPPY");
put("orc.compress.size","524288");
put("hive.exec.orc.default.buffer.size","524288");
put("hive.exec.orc.compression.strategy", "COMPRESSION");
}
}).save("spark_orc_output");
除此之外,我試着在hive-site.xml和hiveContext對象中設置這些屬性。
配置單元 - 輸出上的ororfumpump確認沒有應用配置。 Orcfilingump代碼片段如下。
Compression: ZLIB
Compression size: 262144
我嘗試下面的代碼。它並沒有將zlib的壓縮變成活潑。 SparkConf sc = new SparkConf(); sc.set(「orc.compress」,「snappy」); sc.set(「orc.compress.size」,「524288」); sc.setAppName(「test_orc_config」); JavaSparkContext jsc = new JavaSparkContext(sc); ..... HiveContext hiveContext = new org.apache.spark.sql.hive.HiveContext(jsc.sc()); DataFrame df = hiveContext.createDataFrame(rowData,schema);格式(「orc」)。選項(「壓縮」,「snappy」)。save(「spark_orc_output」); –
我嘗試配置hive-site.xml。它不起作用。 –
所以你最後的選擇是最簡單的選擇:'***。option(「compression」,「snappy」)。***' –