val heightMap=mutable.HashMap[Int,mutable.ArrayBuffer[Double]](1->3.5,2->4.8)
val filteredData =transactions.map{ transaction=>
val filtered=transaction.flatMap(itemToRank.get)
ju.Arrays.sort(filtered)
val tmp: Map[Int, Int] =filtered.zipWithIndex.toMap //Int型的频繁项:频繁项在freqItems中的下标。Map(Int型的频繁项,频繁项在filtered中的下标)
tmp.foreach{case (item,height)=>
val heightArr =heightMap.getOrElseUpdate(item,mutable.ArrayBuffer[Double]())
heightArr+=height
heightMap(item)=heightArr
if(heightMap(item).length>=2)
heightMap(item)=mutable.ArrayBuffer(heightMap(item).max)
}
filtered
} //transactions: RDD[Array[Item]]
就算在上述transactions的map操作中有往heightMap添加元素的操作,最后heightMap的值依然为1->3.5,2->4.8