我不明白下面的代码有什么问题。这工作正常,并且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