I - Vertex idV - Vertex dataE - Edge dataM1 - Incoming message typeM2 - Outgoing message typepublic interface Computation<I extends org.apache.hadoop.io.WritableComparable,V extends org.apache.hadoop.io.Writable,E extends org.apache.hadoop.io.Writable,M1 extends org.apache.hadoop.io.Writable,M2 extends org.apache.hadoop.io.Writable> extends TypesHolder<I,V,E,M1,M2>, ImmutableClassesGiraphConfigurable<I,V,E>, WorkerGlobalCommUsage, WorkerAggregatorUsage, WorkerIndexUsage<I>
Computation,
so accessing any data from this class is thread-safe.
However, accessing global data (like data from WorkerContext)
is not thread-safe.
Objects of this interface only live for a single superstep.| Modifier and Type | Method and Description |
|---|---|
void |
addEdgeRequest(I sourceVertexId,
Edge<I,E> edge)
Request to add an edge of a vertex in the graph
(processed just prior to the next superstep)
|
void |
addVertexRequest(I id,
V value)
Sends a request to create a vertex that will be available during the
next superstep.
|
void |
addVertexRequest(I id,
V value,
OutEdges<I,E> edges)
Sends a request to create a vertex that will be available during the
next superstep.
|
void |
compute(Vertex<I,V,E> vertex,
Iterable<M1> messages)
Must be defined by user to do computation on a single Vertex.
|
org.apache.hadoop.mapreduce.Mapper.Context |
getContext()
Get the mapper context
|
long |
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.
|
<W extends WorkerContext> |
getWorkerContext()
Get the worker context
|
void |
initialize(GraphState graphState,
WorkerClientRequestProcessor<I,V,E> workerClientRequestProcessor,
CentralizedServiceWorker<I,V,E> serviceWorker,
WorkerGlobalCommUsage workerGlobalCommUsage)
Initialize, called by infrastructure before the superstep starts.
|
void |
postSuperstep()
Finish computation.
|
void |
preSuperstep()
Prepare for computation.
|
void |
removeEdgesRequest(I sourceVertexId,
I targetVertexId)
Request to remove all edges from a given source vertex to a given target
vertex (processed just prior to the next superstep).
|
void |
removeVertexRequest(I vertexId)
Request to remove a vertex from the graph
(applied just prior to the next superstep).
|
void |
sendMessage(I id,
M2 message)
Send a message to a vertex id.
|
void |
sendMessageToAllEdges(Vertex<I,V,E> vertex,
M2 message)
Send a message to all edges.
|
void |
sendMessageToMultipleEdges(Iterator<I> vertexIdIterator,
M2 message)
Send a message to multiple target vertex ids in the iterator.
|
getConfsetConfgetBroadcastreduce, reduceMergeaggregategetAggregatedValuegetMyWorkerIndex, getWorkerCount, getWorkerForVertexvoid compute(Vertex<I,V,E> vertex, Iterable<M1> messages) throws IOException
vertex - Vertexmessages - Messages that were sent to this vertex in the previous
superstep. Each message is only guaranteed to have
a life expectancy as long as next() is not called.IOExceptionvoid preSuperstep()
compute(Vertex, Iterable) being called for any of the vertices
in the partition.void postSuperstep()
void initialize(GraphState graphState, WorkerClientRequestProcessor<I,V,E> workerClientRequestProcessor, CentralizedServiceWorker<I,V,E> serviceWorker, WorkerGlobalCommUsage workerGlobalCommUsage)
graphState - Graph stateworkerClientRequestProcessor - Processor for handling requestsserviceWorker - Centralized service workerworkerGlobalCommUsage - Worker global communication usagelong getSuperstep()
long getTotalNumVertices()
long getTotalNumEdges()
void sendMessage(I id, M2 message)
id - Vertex id to send the message tomessage - Message data to sendvoid sendMessageToAllEdges(Vertex<I,V,E> vertex, M2 message)
vertex - Vertex whose edges to send the message to.message - Message sent to all edges.void sendMessageToMultipleEdges(Iterator<I> vertexIdIterator, M2 message)
vertexIdIterator - An iterator to multiple target vertex ids.message - Message sent to all targets in the iterator.void addVertexRequest(I id, V value, OutEdges<I,E> edges) throws IOException
id - Vertex idvalue - Vertex valueedges - Initial edgesIOExceptionvoid addVertexRequest(I id, V value) throws IOException
id - Vertex idvalue - Vertex valueIOExceptionvoid removeVertexRequest(I vertexId) throws IOException
vertexId - Id of the vertex to be removed.IOExceptionvoid addEdgeRequest(I sourceVertexId, Edge<I,E> edge) throws IOException
sourceVertexId - Source vertex id of edgeedge - Edge to addIOExceptionvoid removeEdgesRequest(I sourceVertexId, I targetVertexId) throws IOException
sourceVertexId - Source vertex idtargetVertexId - Target vertex idIOExceptionorg.apache.hadoop.mapreduce.Mapper.Context getContext()
<W extends WorkerContext> W getWorkerContext()
W - WorkerContext classCopyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.