forked from apache/incubator-samoa
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from huafengw/dupEdges
merge duplicated edges in Gearpump's DAG
- Loading branch information
Showing
7 changed files
with
85 additions
and
62 deletions.
There are no files selected for viewing
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
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
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
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
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
38 changes: 38 additions & 0 deletions
38
...arpump/src/main/java/org/apache/samoa/topology/impl/gearpump/SamoaMessagePartitioner.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.apache.samoa.topology.impl.gearpump; | ||
|
||
import io.gearpump.Message; | ||
import io.gearpump.partitioner.*; | ||
import scala.collection.immutable.*; | ||
|
||
public class SamoaMessagePartitioner implements MulticastPartitioner { | ||
ShufflePartitioner shufflePartitioner = new ShufflePartitioner(); | ||
BroadcastPartitioner broadcastPartitioner = new BroadcastPartitioner(); | ||
HashPartitioner hashPartitioner = new HashPartitioner(); | ||
|
||
@Override | ||
public List<Object> getPartitions(Message msg, int partitionNum, int currentPartitionId) { | ||
GearpumpMessage message = (GearpumpMessage) msg.msg(); | ||
Integer partition = -1; | ||
List result = null; | ||
switch (message.getScheme()) { | ||
case SHUFFLE: | ||
partition = shufflePartitioner.getPartition(msg, partitionNum, currentPartitionId); | ||
result = $colon$colon$.MODULE$.apply(partition, (List)Nil$.MODULE$); | ||
break; | ||
case BROADCAST: | ||
result = broadcastPartitioner.getPartitions(msg, partitionNum); | ||
break; | ||
case GROUP_BY_KEY: | ||
//Todo replace HashPartitioner | ||
partition = hashPartitioner.getPartition(msg, partitionNum, currentPartitionId); | ||
result = $colon$colon$.MODULE$.apply(partition, (List)Nil$.MODULE$); | ||
break; | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
public List<Object> getPartitions(Message msg, int partitionNum) { | ||
return this.getPartitions(msg, partitionNum, -1); | ||
} | ||
} |
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