Package org.apache.giraph.graph
Class AbstractComputation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- java.lang.Object
-
- org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable<I,V,E>
-
- org.apache.giraph.worker.WorkerAggregatorDelegator<OID_T,VDATA_T,EDATA_T>
-
- org.apache.giraph.graph.AbstractComputation<OID_T,VDATA_T,EDATA_T,IN_MSG_T,OUT_MSG_T>
-
- Type Parameters:
OID_T
- original vertex id.VDATA_T
- vertex data type.EDATA_T
- edata type.IN_MSG_T
- incoming msg type.OUT_MSG_T
- outgoing msg type.
- All Implemented Interfaces:
org.apache.giraph.aggregators.AggregatorUsage
,org.apache.giraph.conf.GiraphConfigurationSettable<OID_T,VDATA_T,EDATA_T>
,org.apache.giraph.conf.ImmutableClassesGiraphConfigurable<OID_T,VDATA_T,EDATA_T>
,org.apache.giraph.conf.TypesHolder<OID_T,VDATA_T,EDATA_T,IN_MSG_T,OUT_MSG_T>
,org.apache.giraph.graph.Computation<OID_T,VDATA_T,EDATA_T,IN_MSG_T,OUT_MSG_T>
,org.apache.giraph.worker.WorkerAggregatorUsage
,org.apache.giraph.worker.WorkerBroadcastUsage
,org.apache.giraph.worker.WorkerGlobalCommUsage
,org.apache.giraph.worker.WorkerIndexUsage<OID_T>
,org.apache.giraph.worker.WorkerReduceUsage
- Direct Known Subclasses:
org.apache.giraph.graph.BasicComputation
public abstract class AbstractComputation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable> extends WorkerAggregatorDelegator<OID_T,VDATA_T,EDATA_T> implements org.apache.giraph.graph.Computation<OID_T,VDATA_T,EDATA_T,IN_MSG_T,OUT_MSG_T>
Implement all methods in Computation other than compute, which left for user to define.
-
-
Constructor Summary
Constructors Constructor Description AbstractComputation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEdgeRequest(OID_T sourceVertexId, org.apache.giraph.edge.Edge<OID_T,EDATA_T> edge)
void
addVertexRequest(OID_T id, VDATA_T value)
void
addVertexRequest(OID_T id, VDATA_T value, org.apache.giraph.edge.OutEdges<OID_T,EDATA_T> edges)
org.apache.hadoop.mapreduce.Mapper.Context
getContext()
Get the mapper contextint
getMyWorkerIndex()
Get index for this workerlong
getSuperstep()
Retrieves the current superstep.long
getTotalNumEdges()
Get the total (all workers) number of edges that existed in the previous superstep.long
getTotalNumVertices()
Get the total (all workers) number of vertices that existed in the previous superstep.WorkerContext
getWorkerContext()
Get the worker contextint
getWorkerCount()
Get number of workersint
getWorkerForVertex(OID_T vertexId)
Get worker index which will contain vertex with given id, if such vertex exists.void
incStep()
Called by our framework after each super step.void
initialize(org.apache.giraph.graph.GraphState graphState, org.apache.giraph.comm.WorkerClientRequestProcessor<OID_T,VDATA_T,EDATA_T> workerClientRequestProcessor, org.apache.giraph.bsp.CentralizedServiceWorker<OID_T,VDATA_T,EDATA_T> serviceWorker, org.apache.giraph.worker.WorkerGlobalCommUsage workerGlobalCommUsage)
void
postSuperstep()
Finish computation.void
preSuperstep()
Prepare for computation.void
removeEdgesRequest(OID_T sourceVertexId, OID_T targetVertexId)
void
removeVertexRequest(OID_T vertexId)
void
sendMessage(OID_T id, OUT_MSG_T message)
void
sendMessageToAllEdges(org.apache.giraph.graph.Vertex<OID_T,VDATA_T,EDATA_T> vertex, OUT_MSG_T message)
void
sendMessageToMultipleEdges(Iterator<OID_T> vertexIdIterator, OUT_MSG_T message)
void
setFragment(IFragment fragment)
void
setGiraphMessageManager(GiraphMessageManager<OID_T,VDATA_T,EDATA_T,IN_MSG_T,OUT_MSG_T,?,?> giraphMessageManager)
void
setWorkerContext(WorkerContext workerContext)
-
Methods inherited from class org.apache.giraph.worker.WorkerAggregatorDelegator
aggregate, getAggregatedValue, getBroadcast, reduce, reduceMerge, setAggregatorManager
-
Methods inherited from class org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable
getConf, setConf
-
-
-
-
Method Detail
-
setGiraphMessageManager
public void setGiraphMessageManager(GiraphMessageManager<OID_T,VDATA_T,EDATA_T,IN_MSG_T,OUT_MSG_T,?,?> giraphMessageManager)
-
setFragment
public void setFragment(IFragment fragment)
-
incStep
public void incStep()
Called by our framework after each super step.
-
preSuperstep
public void preSuperstep()
Prepare for computation. This method is executed exactly once prior toComputation.compute(Vertex, Iterable)
being called for any of the vertices in the partition.- Specified by:
preSuperstep
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
-
postSuperstep
public void postSuperstep()
Finish computation. This method is executed exactly once after computation for all vertices in the partition is complete.- Specified by:
postSuperstep
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
-
getSuperstep
public long getSuperstep()
Retrieves the current superstep.- Specified by:
getSuperstep
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Returns:
- Current superstep
-
getTotalNumVertices
public long getTotalNumVertices()
Get the total (all workers) number of vertices that existed in the previous superstep.- Specified by:
getTotalNumVertices
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Returns:
- Total number of vertices (-1 if first superstep)
-
getTotalNumEdges
public long getTotalNumEdges()
Get the total (all workers) number of edges that existed in the previous superstep.- Specified by:
getTotalNumEdges
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Returns:
- Total number of edges (-1 if first superstep)
-
getContext
public org.apache.hadoop.mapreduce.Mapper.Context getContext()
Get the mapper context- Specified by:
getContext
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Returns:
- Mapper context
-
getWorkerContext
public WorkerContext getWorkerContext()
Get the worker context- Specified by:
getWorkerContext
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Returns:
- WorkerContext context
-
setWorkerContext
public void setWorkerContext(WorkerContext workerContext)
-
addVertexRequest
public void addVertexRequest(OID_T id, VDATA_T value, org.apache.giraph.edge.OutEdges<OID_T,EDATA_T> edges) throws IOException
- Specified by:
addVertexRequest
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Throws:
IOException
-
addVertexRequest
public void addVertexRequest(OID_T id, VDATA_T value) throws IOException
- Specified by:
addVertexRequest
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Throws:
IOException
-
removeVertexRequest
public void removeVertexRequest(OID_T vertexId) throws IOException
- Specified by:
removeVertexRequest
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Throws:
IOException
-
addEdgeRequest
public void addEdgeRequest(OID_T sourceVertexId, org.apache.giraph.edge.Edge<OID_T,EDATA_T> edge) throws IOException
- Specified by:
addEdgeRequest
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Throws:
IOException
-
removeEdgesRequest
public void removeEdgesRequest(OID_T sourceVertexId, OID_T targetVertexId) throws IOException
- Specified by:
removeEdgesRequest
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
- Throws:
IOException
-
sendMessage
public void sendMessage(OID_T id, OUT_MSG_T message)
- Specified by:
sendMessage
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
-
sendMessageToAllEdges
public void sendMessageToAllEdges(org.apache.giraph.graph.Vertex<OID_T,VDATA_T,EDATA_T> vertex, OUT_MSG_T message)
- Specified by:
sendMessageToAllEdges
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
-
sendMessageToMultipleEdges
public void sendMessageToMultipleEdges(Iterator<OID_T> vertexIdIterator, OUT_MSG_T message)
- Specified by:
sendMessageToMultipleEdges
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
-
getWorkerCount
public int getWorkerCount()
Get number of workers- Specified by:
getWorkerCount
in interfaceorg.apache.giraph.worker.WorkerIndexUsage<OID_T extends org.apache.hadoop.io.WritableComparable>
- Returns:
- Number of workers
-
getMyWorkerIndex
public int getMyWorkerIndex()
Get index for this worker- Specified by:
getMyWorkerIndex
in interfaceorg.apache.giraph.worker.WorkerIndexUsage<OID_T extends org.apache.hadoop.io.WritableComparable>
- Returns:
- Index of this worker
-
getWorkerForVertex
public int getWorkerForVertex(OID_T vertexId)
Get worker index which will contain vertex with given id, if such vertex exists.- Specified by:
getWorkerForVertex
in interfaceorg.apache.giraph.worker.WorkerIndexUsage<OID_T extends org.apache.hadoop.io.WritableComparable>
- Parameters:
vertexId
- vertex id- Returns:
- worker index
-
initialize
public void initialize(org.apache.giraph.graph.GraphState graphState, org.apache.giraph.comm.WorkerClientRequestProcessor<OID_T,VDATA_T,EDATA_T> workerClientRequestProcessor, org.apache.giraph.bsp.CentralizedServiceWorker<OID_T,VDATA_T,EDATA_T> serviceWorker, org.apache.giraph.worker.WorkerGlobalCommUsage workerGlobalCommUsage)
- Specified by:
initialize
in interfaceorg.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,VDATA_T extends org.apache.hadoop.io.Writable,EDATA_T extends org.apache.hadoop.io.Writable,IN_MSG_T extends org.apache.hadoop.io.Writable,OUT_MSG_T extends org.apache.hadoop.io.Writable>
-
-