0
下面是我的代碼片段。我有DStream,我試圖將它保存到HDFS。只是想知道壓縮的有效方法。rdd.saveAsTextFile在foreachRDD內的驅動程序或工作程序上執行。
pairedDStream.foreachRDD { rdd =>
val time = Calendar.getInstance.getTimeInMillis;
val textOutputFolder = outputDir + "/output-" + time
if (args.length == 4) {
val compressionCodec = args(3)
rdd.saveAsTextFile(textOutputFolder, CommonUtils.getCompressionCodec(compressionCodec))
} else {
rdd.saveAsTextFile(textOutputFolder, CommonUtils.getCompressionCodec(null))
}
}