Ist dataframe.show () eine Aktion im Funken?

Ich habe den folgenden Code:

val df_in = sqlcontext.read.json(jsonFile) // the file resides in hdfs

//some operations in here to create df as df_in with two more columns "terms1" and "terms2" 

val intersectUDF = udf( (seq1:Seq[String], seq2:Seq[String] ) => {     seq1 intersect seq2 } ) //intersects two sequences
val symmDiffUDF = udf( (seq1:Seq[String], seq2:Seq[String] ) => { (seq1 diff seq2) ++ (seq2 diff seq1) } ) //compute the difference of two sequences

val df1 = (df.withColumn("termsInt", intersectUDF(df("terms1"), df1("terms2") ) )
             .withColumn("termsDiff", symmDiffUDF(df("terms1"),     df1("terms2") ) )
             .where( size(col("termsInt")) >0 && size(col("termsDiff")) > 0 && size(col("termsDiff")) <= 2 )
             .cache()
           ) // add the intersection and difference columns and filter the resulting DF 

df1.show()
df1.count()

Die App funktioniert einwandfrei und schnell, bis dasshow() aber in dercount() step erstellt 40000 Aufgaben.

ein Verständnis ist, dassdf1.show() sollte das volle @ auslösdf1 Schöpfung unddf1.count() sollte sehr schnell sein. Was vermisse ich hier? warum istcount() so langsam?

Vielen Dank im Voraus, Roxana

Antworten auf die Frage(2)

Ihre Antwort auf die Frage