forked from apache/giraph
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
605c308
commit 7e39f91
Showing
37 changed files
with
1,280 additions
and
499 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
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
90 changes: 90 additions & 0 deletions
90
giraph-core/src/main/java/org/apache/giraph/graph/GiraphSubgraphComputation.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,90 @@ | ||
package org.apache.giraph.graph; | ||
|
||
import org.apache.commons.lang3.NotImplementedException; | ||
import org.apache.giraph.comm.messages.SubgraphMessage; | ||
import org.apache.giraph.conf.ClassConfOption; | ||
import org.apache.giraph.utils.ReflectionUtils; | ||
import org.apache.hadoop.io.Writable; | ||
import org.apache.hadoop.io.WritableComparable; | ||
import org.apache.log4j.Logger; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Created by anirudh on 27/09/16. | ||
* | ||
* @param <S> Subgraph id | ||
* @param <I> Vertex id | ||
* @param <V> Vertex value | ||
* @param <E> Edge data | ||
* @param <M> Message type | ||
* @param <SV> Subgraph Value type | ||
*/ | ||
|
||
|
||
// S subgraph value type ----- SV now | ||
// V vertex object type -- V is the vertex value | ||
// E edge value type -- E is the edge value | ||
// M msg object type -- M is the message value type | ||
// I vertex id --- I is the vertex id here | ||
// J edge id -- EI | ||
// K subgraph id ---- S | ||
|
||
public class GiraphSubgraphComputation<S extends WritableComparable, | ||
I extends WritableComparable, V extends WritableComparable, E extends Writable, M extends Writable, SV extends Writable, EI extends WritableComparable> extends BasicComputation<SubgraphId<S>, SubgraphVertices<S, I, V, E, SV, EI>, E, SubgraphMessage<S, M>> { | ||
|
||
private static final Logger LOG = Logger.getLogger(GiraphSubgraphComputation.class); | ||
|
||
private static final ClassConfOption<UserSubgraphComputation> SUBGRAPH_COMPUTATION_CLASS = ClassConfOption.create("subgraphComputationClass", | ||
null, UserSubgraphComputation.class, "Subgraph Computation Class"); | ||
|
||
private UserSubgraphComputation<S, I, V, E, M, SV, EI> userSubgraphComputation; | ||
|
||
// TODO: Have class be specified in conf | ||
|
||
DefaultSubgraph<S, I, V, E, SV, EI> subgraph; | ||
|
||
public Subgraph<S, I, V, E, SV, EI> getSubgraph() { | ||
return subgraph; | ||
} | ||
// TODO: Take care of state changes for the subgraph passed | ||
|
||
public void compute(Vertex<SubgraphId<S>, SubgraphVertices<S, I, V, E, SV, EI>, E> vertex, Iterable<SubgraphMessage<S, M>> messages) throws IOException { | ||
Class userSubgraphComputationClass; | ||
long superstep = getSuperstep(); | ||
if (superstep == 0) { | ||
userSubgraphComputationClass = RemoteVerticesFinder.class; | ||
} else if (superstep == 1) { | ||
userSubgraphComputationClass = RemoteVerticesFinder2.class; | ||
} else if (superstep == 2) { | ||
userSubgraphComputationClass = RemoteVerticesFinder3.class; | ||
} else { | ||
userSubgraphComputationClass = SUBGRAPH_COMPUTATION_CLASS.get(getConf()); | ||
LOG.info("User Class: " + userSubgraphComputationClass); | ||
} | ||
userSubgraphComputation = (UserSubgraphComputation<S, I, V, E, M, SV, EI>) ReflectionUtils.newInstance(userSubgraphComputationClass, getConf()); | ||
LOG.info("User Object: " + userSubgraphComputation); | ||
userSubgraphComputation.setGiraphSubgraphComputation(this); | ||
subgraph = (DefaultSubgraph) vertex; | ||
userSubgraphComputation.compute(messages); | ||
} | ||
|
||
public void sendMessageToAllNeighboringSubgraphs(M message) { | ||
WritableComparable subgraphId = subgraph.getSubgraphId(); | ||
SubgraphMessage sm = new SubgraphMessage(subgraphId, message); | ||
super.sendMessageToAllEdges(subgraph, sm); | ||
} | ||
|
||
public void sendMessage(SubgraphId<S> subgraphId, M message) { | ||
SubgraphMessage sm = new SubgraphMessage(subgraphId.getSubgraphId(), message); | ||
sendMessage(subgraphId, sm); | ||
} | ||
|
||
public void voteToHalt() { | ||
subgraph.voteToHalt(); | ||
} | ||
|
||
SubgraphEdge<I, E, EI> getEdgeById(EI id) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
giraph-core/src/main/java/org/apache/giraph/graph/GiraphSubgraphComputationImpl.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,12 @@ | ||
package org.apache.giraph.graph; | ||
|
||
import org.apache.hadoop.io.BytesWritable; | ||
import org.apache.hadoop.io.DoubleWritable; | ||
import org.apache.hadoop.io.LongWritable; | ||
import org.apache.hadoop.io.NullWritable; | ||
|
||
/** | ||
* Created by anirudh on 02/03/17. | ||
*/ | ||
public class GiraphSubgraphComputationImpl extends GiraphSubgraphComputation<LongWritable, LongWritable, DoubleWritable, DoubleWritable, BytesWritable, NullWritable, LongWritable>{ | ||
} |
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
Oops, something went wrong.