I am running a sequence model in Spark using Scala API. This is the line of code to see the outcome:
model.freqSequences.collect().foreach { freqSequence => println(freqSequence.sequence.map(_.mkString("[", ", ", "]")).mkString("[", ", ", "]") + ", " + freqSequence.freq)}
The problem is the outcome is getting big and don't want to use collect() anymore but saving it in a file either in HDFS or local. I tried this:
scala> val outcome = model.freqSequences.foreach { freqSequence => println(freqSequence.sequence.map(_.mkString("[", ", ", "]")).mkString("[", ", ", "]") + ", " + freqSequence.freq)}
scala> outcome.saveAsTextFile("tmp/outcome1/")
error: saveAsTextFile is not a member of Unit
The outcome is a Unit and I am not able to use saveAsTextFile. Any other way to save this outcome? Txs.