@@ -44,7 +44,7 @@ object ShippableVertexPartition {
44
44
*/
45
45
def apply [VD : ClassTag ](
46
46
iter : Iterator [(VertexId , VD )], routingTable : RoutingTablePartition , defaultVal : VD )
47
- : ShippableVertexPartition [VD ] =
47
+ : ShippableVertexPartition [VD ] =
48
48
apply(iter, routingTable, defaultVal, (a, b) => a)
49
49
50
50
/**
@@ -54,12 +54,18 @@ object ShippableVertexPartition {
54
54
*/
55
55
def apply [VD : ClassTag ](
56
56
iter : Iterator [(VertexId , VD )], routingTable : RoutingTablePartition , defaultVal : VD ,
57
- mergeFunc : (VD , VD ) => VD
58
- )
59
- : ShippableVertexPartition [VD ] = {
60
- val fullIter = iter ++ routingTable.iterator.map(vid => (vid, defaultVal))
61
- val (index, values, mask) = VertexPartitionBase .initFrom(fullIter, mergeFunc)
62
- new ShippableVertexPartition (index, values, mask, routingTable)
57
+ mergeFunc : (VD , VD ) => VD ): ShippableVertexPartition [VD ] = {
58
+ val map = new GraphXPrimitiveKeyOpenHashMap [VertexId , VD ]
59
+ // Merge the given vertices using mergeFunc
60
+ iter.foreach { pair =>
61
+ map.setMerge(pair._1, pair._2, mergeFunc)
62
+ }
63
+ // Fill in missing vertices mentioned in the routing table
64
+ routingTable.iterator.foreach { vid =>
65
+ map.changeValue(vid, defaultVal, identity)
66
+ }
67
+
68
+ new ShippableVertexPartition (map.keySet, map._values, map.keySet.getBitSet, routingTable)
63
69
}
64
70
65
71
import scala .language .implicitConversions
0 commit comments