Github user SereneAnt commented on a diff in the pull request: https://github.com/apache/spark/pull/18693#discussion_r128635631 --- Diff: graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala --- @@ -199,10 +199,10 @@ object PageRank extends Logging { require(sources.max <= Int.MaxValue.toLong, s"This implementation currently only works for source vertex ids at most ${Int.MaxValue}") val zero = Vectors.sparse(sources.size, List()).asBreeze - val sourcesInitMap = sources.zipWithIndex.map { case (vid, i) => + val sourcesInitMap: Map[VertexId, BV[Double]] = sources.zipWithIndex.map { case (vid, i) => val v = Vectors.sparse(sources.size, Array(i), Array(1.0)).asBreeze (vid, v) - }.toMap + }(collection.breakOut) --- End diff -- The principles are the same, `sources.zipWithIndex.map {...}' allocates a collection of tuples, `.toMap` then uterates and converts them into the map (hehe). breakOut is the implementation of CanBuildFrom, the implicit parameter passed to `Traversable.map` method. Once used, it allows populating newborn map directly, without intermediate collection of tuples.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org