我不明白下面的代碼有什麼問題。這工作正常,並且hashmap typeMap
得到更新,如果我的輸入數據框未分區。但是,如果下面的代碼在分區環境中執行,則typeMap
始終爲空且不會更新。這段代碼有什麼問題?感謝你的幫助。斯卡拉hashmap沒有被追加
var typeMap = new mutable.HashMap[String, (String, Array[String])]
case class Combiner(,,,,,,, mapTypes: mutable.HashMap[String, (String, Array[String])]) {
def execute() {
<...>
val combinersResult = dfInput.rdd.aggregate(combiners.toArray) (incrementCount, mergeCount)
}
def updateTypes(arr: Array[String], tempMapTypes:mutable.HashMap[String, (String, Array[String])]): Unit = {
<...>
typeMap ++= tempMapTypes
}
def incrementCount(combiners: Array[Combiner], row: Row): Array[Combiner] = {
for (i <- 0 until row.length) {
val array = getMyType(row(i), tempMapTypes)
combiners(i). updateTypes(array, tempMapTypes)
}
combiners
}
嗨,有什麼線索嗎? – Garipaso