Skip to content

Latest commit

 

History

History
30 lines (20 loc) · 1.02 KB

spark-streaming-operators-saveas.adoc

File metadata and controls

30 lines (20 loc) · 1.02 KB

SaveAs Operators

There are two saveAs operators in DStream:

  • saveAsObjectFiles

  • saveAsTextFiles

They are output operators that return nothing as they save each RDD in a batch to a storage.

Their full signature is as follows:

saveAsObjectFiles(prefix: String, suffix: String = ""): Unit
saveAsTextFiles(prefix: String, suffix: String = ""): Unit
Note
SaveAs operators use foreachRDD output operator.

saveAsObjectFiles uses RDD.saveAsObjectFile while saveAsTextFiles uses RDD.saveAsTextFile.

The file name is based on mandatory prefix and batch time with optional suffix. It is in the format of [prefix]-[time in milliseconds].[suffix].

Example

val clicks: InputDStream[(String, String)] = messages
clicks.saveAsTextFiles("clicks", "txt")