@@ -64,6 +64,7 @@ class EdgePartition[
6464 activeSet : Option [VertexSet ])
6565 extends Serializable {
6666
67+ /** No-arg constructor for serialization. */
6768 private def this () = this (null , null , null , null , null , null , null , null )
6869
6970 /** Return a new `EdgePartition` with the specified edge data. */
@@ -375,22 +376,15 @@ class EdgePartition[
375376 * @param sendMsg generates messages to neighboring vertices of an edge
376377 * @param mergeMsg the combiner applied to messages destined to the same vertex
377378 * @param tripletFields which triplet fields `sendMsg` uses
378- * @param srcMustBeActive if true, edges will only be considered if their source vertex is in the
379- * active set
380- * @param dstMustBeActive if true, edges will only be considered if their destination vertex is in
381- * the active set
382- * @param maySatisfyEither if true, only one vertex need be in the active set for an edge to be
383- * considered
379+ * @param activeness criteria for filtering edges based on activeness
384380 *
385381 * @return iterator aggregated messages keyed by the receiving vertex id
386382 */
387383 def aggregateMessagesEdgeScan [A : ClassTag ](
388384 sendMsg : EdgeContext [VD , ED , A ] => Unit ,
389385 mergeMsg : (A , A ) => A ,
390386 tripletFields : TripletFields ,
391- srcMustBeActive : Boolean ,
392- dstMustBeActive : Boolean ,
393- maySatisfyEither : Boolean ): Iterator [(VertexId , A )] = {
387+ activeness : EdgeActiveness ): Iterator [(VertexId , A )] = {
394388 val aggregates = new Array [A ](vertexAttrs.length)
395389 val bitset = new BitSet (vertexAttrs.length)
396390
@@ -401,10 +395,13 @@ class EdgePartition[
401395 val srcId = local2global(localSrcId)
402396 val localDstId = localDstIds(i)
403397 val dstId = local2global(localDstId)
404- val srcIsActive = ! srcMustBeActive || isActive(srcId)
405- val dstIsActive = ! dstMustBeActive || isActive(dstId)
406398 val edgeIsActive =
407- if (maySatisfyEither) srcIsActive || dstIsActive else srcIsActive && dstIsActive
399+ if (activeness == EdgeActiveness .Neither ) true
400+ else if (activeness == EdgeActiveness .SrcOnly ) isActive(srcId)
401+ else if (activeness == EdgeActiveness .DstOnly ) isActive(dstId)
402+ else if (activeness == EdgeActiveness .Both ) isActive(srcId) && isActive(dstId)
403+ else if (activeness == EdgeActiveness .Either ) isActive(srcId) || isActive(dstId)
404+ else throw new Exception (" unreachable" )
408405 if (edgeIsActive) {
409406 val srcAttr = if (tripletFields.useSrc) vertexAttrs(localSrcId) else null .asInstanceOf [VD ]
410407 val dstAttr = if (tripletFields.useDst) vertexAttrs(localDstId) else null .asInstanceOf [VD ]
@@ -424,22 +421,15 @@ class EdgePartition[
424421 * @param sendMsg generates messages to neighboring vertices of an edge
425422 * @param mergeMsg the combiner applied to messages destined to the same vertex
426423 * @param tripletFields which triplet fields `sendMsg` uses
427- * @param srcMustBeActive if true, edges will only be considered if their source vertex is in the
428- * active set
429- * @param dstMustBeActive if true, edges will only be considered if their destination vertex is in
430- * the active set
431- * @param maySatisfyEither if true, only one vertex need be in the active set for an edge to be
432- * considered
424+ * @param activeness criteria for filtering edges based on activeness
433425 *
434426 * @return iterator aggregated messages keyed by the receiving vertex id
435427 */
436428 def aggregateMessagesIndexScan [A : ClassTag ](
437429 sendMsg : EdgeContext [VD , ED , A ] => Unit ,
438430 mergeMsg : (A , A ) => A ,
439431 tripletFields : TripletFields ,
440- srcMustBeActive : Boolean ,
441- dstMustBeActive : Boolean ,
442- maySatisfyEither : Boolean ): Iterator [(VertexId , A )] = {
432+ activeness : EdgeActiveness ): Iterator [(VertexId , A )] = {
443433 val aggregates = new Array [A ](vertexAttrs.length)
444434 val bitset = new BitSet (vertexAttrs.length)
445435
@@ -448,18 +438,30 @@ class EdgePartition[
448438 val clusterSrcId = cluster._1
449439 val clusterPos = cluster._2
450440 val clusterLocalSrcId = localSrcIds(clusterPos)
451- val srcIsActive = ! srcMustBeActive || isActive(clusterSrcId)
452- if (srcIsActive || maySatisfyEither) {
441+
442+ val scanCluster =
443+ if (activeness == EdgeActiveness .Neither ) true
444+ else if (activeness == EdgeActiveness .SrcOnly ) isActive(clusterSrcId)
445+ else if (activeness == EdgeActiveness .DstOnly ) true
446+ else if (activeness == EdgeActiveness .Both ) isActive(clusterSrcId)
447+ else if (activeness == EdgeActiveness .Either ) true
448+ else throw new Exception (" unreachable" )
449+
450+ if (scanCluster) {
453451 var pos = clusterPos
454452 val srcAttr =
455453 if (tripletFields.useSrc) vertexAttrs(clusterLocalSrcId) else null .asInstanceOf [VD ]
456454 ctx.setSrcOnly(clusterSrcId, clusterLocalSrcId, srcAttr)
457455 while (pos < size && localSrcIds(pos) == clusterLocalSrcId) {
458456 val localDstId = localDstIds(pos)
459457 val dstId = local2global(localDstId)
460- val dstIsActive = ! dstMustBeActive || isActive(dstId)
461458 val edgeIsActive =
462- if (maySatisfyEither) srcIsActive || dstIsActive else srcIsActive && dstIsActive
459+ if (activeness == EdgeActiveness .Neither ) true
460+ else if (activeness == EdgeActiveness .SrcOnly ) true
461+ else if (activeness == EdgeActiveness .DstOnly ) isActive(dstId)
462+ else if (activeness == EdgeActiveness .Both ) isActive(dstId)
463+ else if (activeness == EdgeActiveness .Either ) isActive(clusterSrcId) || isActive(dstId)
464+ else throw new Exception (" unreachable" )
463465 if (edgeIsActive) {
464466 val dstAttr =
465467 if (tripletFields.useDst) vertexAttrs(localDstId) else null .asInstanceOf [VD ]
0 commit comments