for (fordate <- 2 to 30) {
val dataRDD = sc.textFile("s3n://mypath" + fordate + "/*")
val a = 1
val c = fordate - 1
for (b <- a to c) {
val cumilativeRDD1 = sc.textFile("s3n://mypath/" + b + "/*")
val cumilativeRDD : org.apache.spark.rdd.RDD[String] = sc.union(cumilativeRDD1, cumilativeRDD)
if (b == c) {
val incrementalDEviceIDs = dataRDD.subtract(cumilativeRDD)
val countofIDs = incrementalDEviceIDs.distinct().count()
println(s"201611 $fordate $countofIDs")
}
}
}
我有一個數據集,我每天都會得到deviceID。我需要弄清楚每天的增量計數,但是當我加入cumilativeRDD
到它本身saysthrows以下錯誤:斯卡拉 - 將RDD附加到自身
forward reference extends over definition of value cumilativeRDD
我怎樣才能克服這一點。
目前尚不清楚你想要達到的目標。你能描述這個過程的意圖嗎? – maasg
因此,如果正確地明白的*意圖*是diff的'天[X]'與'總和[1,X-1](天[I])'。除了解決變量範圍的問題之外,這個實現對於來自網絡的數據是n^2。您閱讀「第1天」,「第2天」,「第n」次,...。我建議您檢查一下您的流程,以累計所看到的數據並進行比較。 – maasg