public abstract class JythonComputation extends DefaultImmutableClassesGiraphConfigurable
Computation
.
This is because we want to support passing in pure Jython types,
and implementing the Computation
requires passing in Writable
s.
Calling such methods from Jython would throw errors. So, instead,
we have recreated the methods with the same name here. In each method
we check if the type is a pure Jython value, and if so wrap it in
the necessary
JythonWritableWrapper
.
This class works together with JythonGiraphComputation
which takes
care of the Computation
Giraph infrastructure side of things.Constructor and Description |
---|
JythonComputation() |
Modifier and Type | Method and Description |
---|---|
void |
addEdgeRequest(Object sourceVertexId,
Edge edge)
Request to add an edge of a vertex in the graph
(processed just prior to the next superstep)
|
void |
addVertexRequest(Object id,
Object vertexValue)
Sends a request to create a vertex that will be available during the
next superstep.
|
void |
addVertexRequest(Object id,
Object vertexValue,
OutEdges edges)
Sends a request to create a vertex that will be available during the
next superstep.
|
abstract void |
compute(Object vertex,
Iterable messages)
User's computation function
|
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 |
postSuperstep()
Finish computation.
|
void |
preSuperstep()
Prepare for computation.
|
void |
removeEdgesRequest(Object sourceVertexId,
Object 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(Object id)
Request to remove a vertex from the graph
(applied just prior to the next superstep).
|
void |
sendMessage(Object id,
Object message)
Send a message to a vertex id.
|
void |
sendMessageToAllEdges(Vertex vertex,
Object message)
Send a message to all edges.
|
void |
sendMessageToMultipleEdges(Iterator vertexIdIterator,
Object message)
Send a message to multiple target vertex ids in the iterator.
|
void |
setGiraphCompute(JythonGiraphComputation giraphCompute) |
getConf, setConf
public void setGiraphCompute(JythonGiraphComputation giraphCompute)
public abstract void compute(Object vertex, Iterable messages)
vertex
- the Vertex to compute onmessages
- iterable of messagespublic void preSuperstep()
compute(Object, Iterable)
being called for any of the vertices
in the partition.public void postSuperstep()
public long getSuperstep()
public long getTotalNumVertices()
public long getTotalNumEdges()
public void sendMessage(Object id, Object message)
id
- Vertex id to send the message tomessage
- Message data to sendpublic void sendMessageToAllEdges(Vertex vertex, Object message)
vertex
- Vertex whose edges to send the message to.message
- Message sent to all edges.public void sendMessageToMultipleEdges(Iterator vertexIdIterator, Object message)
vertexIdIterator
- An iterator to multiple target vertex ids.message
- Message sent to all targets in the iterator.public void addVertexRequest(Object id, Object vertexValue, OutEdges edges) throws IOException
id
- Vertex idvertexValue
- Vertex valueedges
- Initial edgesIOException
public void addVertexRequest(Object id, Object vertexValue) throws IOException
id
- Vertex idvertexValue
- Vertex valueIOException
public void removeVertexRequest(Object id) throws IOException
id
- Id of the vertex to be removed.IOException
public void addEdgeRequest(Object sourceVertexId, Edge edge) throws IOException
sourceVertexId
- Source vertex id of edgeedge
- Edge to addIOException
public void removeEdgesRequest(Object sourceVertexId, Object targetVertexId) throws IOException
sourceVertexId
- Source vertex idtargetVertexId
- Target vertex idIOException
public org.apache.hadoop.mapreduce.Mapper.Context getContext()
public <W extends WorkerContext> W getWorkerContext()
W
- WorkerContext classCopyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.