Home > other >  The spark of a primary issue
The spark of a primary issue

Time:09-26

Just learning soon spark,
Encounter a problem,
I know the count of the action and saveAsTextFile,

Now I want to count the results into the file, how to do?

Can't data. * * *. Count. SaveAsTextFile (* *)

Thank you,

CodePudding user response:

Can't, saveAsTextFile (RDD), the method of action do the count returned is Long, want to write to the file, needs to be converted to a String, and then invokes the Java IO stream to a file

CodePudding user response:

You can use this long Numbers and build a new RDD object, then saveAsTextFile () is stored

CodePudding user response:

After the count is a numeric value, directly in the Java method had written to the file,
  • Related