0
我正在尝试更新数组中的哈希映射,但无法这样做。哈希映射在scala中追加
def incrementCount(combiners: Array[Combiner], row: Row): Array[Combiner] = {
val tempMapTypes = new scala.collection.mutable.HashMap[String, (String, Array[String])]
for (i <- 0 until row.length) {
val array = getMyType(row(i), tempMapTypes)
for (elem <- tempMapTypes) {
combiners(i).mapTypes.update(elem._1,elem._2) <<<< this update doesnt work for me, always mapTypes is empty
}
}
}
这是合班
case class Combiner(<other variables>, mapTypes: mutable.HashMap[String, (String, Array[String])])
combiners
}
这是怎么回事,它的另一种方法得到了初始化...
val mapTypes = new scala.collection.mutable.HashMap[String, (String, Array[String])]
combiners += new Combiner(....,mapTypes)
正如上面提到的,这种情况下的初始化之后类,如何追加mapTypes,上述更新代码似乎不适合我。