Created
January 17, 2017 21:50
-
-
Save TRBaldim/ca8cadecd0c97ff474c44c105817868a to your computer and use it in GitHub Desktop.
Update Immutable Map in Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def updateMap[A, B](map: Map[A, List[B]], key: A, value: B) = | |
map + ((key, map.getOrElse(key, List()) ::: List(value))) | |
var topicsMap = offsetsRanges.map { o => (o.topic, List[String]())}.toMap | |
offsetsRanges.foreach { o => | |
topicsMap = updateMap[String, String](topicsMap, o.topic, (o.partition + ":" + o.untilOffset))} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment