Skip to content
Snippets Groups Projects
Commit bf19aac2 authored by Ankur Dave's avatar Ankur Dave
Browse files

Use ArrayBuilder instead of ArrayBuffer

ArrayBuilder is specialized for holding primitive VD types.
parent 2282d27c
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ import scala.collection.JavaConversions._ ...@@ -4,6 +4,7 @@ import scala.collection.JavaConversions._
import scala.collection.mutable import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.ArrayBuilder
import org.apache.spark.SparkContext._ import org.apache.spark.SparkContext._
import org.apache.spark.Partitioner import org.apache.spark.Partitioner
...@@ -501,11 +502,11 @@ object GraphImpl { ...@@ -501,11 +502,11 @@ object GraphImpl {
val vTableReplicatedValues: IndexedRDD[Pid, Array[VD]] = val vTableReplicatedValues: IndexedRDD[Pid, Array[VD]] =
msgsByPartition.mapPartitionsWithIndex( (pid, iter) => { msgsByPartition.mapPartitionsWithIndex( (pid, iter) => {
val vertexArray = new ArrayBuffer[VD] val vertexArray = ArrayBuilder.make[VD]
for (msg <- iter) { for (msg <- iter) {
vertexArray += msg.data._2 vertexArray += msg.data._2
} }
Array((pid, vertexArray.toArray)).iterator Array((pid, vertexArray.result)).iterator
}, preservesPartitioning = true).indexed(eTable.index) }, preservesPartitioning = true).indexed(eTable.index)
(vTableReplicationMap, vTableReplicatedValues) (vTableReplicationMap, vTableReplicatedValues)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment