K
- The type of the vertex key (the vertex identifier).VV
- The type of the vertex value (the state of the vertex).EV
- The type of the values that are associated with the edges.Message
- The type of the message sent between vertices along the edges.public abstract class ComputeFunction<K,VV,EV,Message> extends Object implements Serializable
VertexCentricIteration
.Constructor and Description |
---|
ComputeFunction() |
Modifier and Type | Method and Description |
---|---|
abstract void |
compute(Vertex<K,VV> vertex,
MessageIterator<Message> messages)
This method is invoked once per superstep, for each active vertex.
|
<T> Collection<T> |
getBroadcastSet(String name)
Gets the broadcast data set registered under the given name.
|
Iterable<Edge<K,EV>> |
getEdges()
Gets an
Iterable with all out-going edges. |
<T extends Aggregator<?>> |
getIterationAggregator(String name)
Gets the iteration aggregator registered under the given name.
|
<T extends Value> |
getPreviousIterationAggregate(String name)
Get the aggregated value that an aggregator computed in the previous iteration.
|
int |
getSuperstepNumber()
Gets the number of the superstep, starting at 1.
|
void |
postSuperstep()
This method is executed once per superstep after the vertex update function has been invoked
for each vertex.
|
void |
preSuperstep()
This method is executed once per superstep before the vertex update function is invoked for
each vertex.
|
void |
sendMessageTo(K target,
Message m)
Sends the given message to the vertex identified by the given key.
|
void |
sendMessageToAllNeighbors(Message m)
Sends the given message to all vertices that adjacent to the changed vertex.
|
void |
setNewVertexValue(VV newValue)
Sets the new value of this vertex.
|
public abstract void compute(Vertex<K,VV> vertex, MessageIterator<Message> messages) throws Exception
This method can iterate over all received messages, set the new vertex value, and send messages to other vertices (which will be delivered in the next superstep).
vertex
- The vertex executing this functionmessages
- The messages that were sent to this vertex in the previous superstepException
public void preSuperstep() throws Exception
Exception
- Exceptions in the pre-superstep phase cause the superstep to fail.public void postSuperstep() throws Exception
Exception
- Exceptions in the post-superstep phase cause the superstep to fail.public final Iterable<Edge<K,EV>> getEdges()
Iterable
with all out-going edges. This method is mutually
exclusive with sendMessageToAllNeighbors(Object)
and may be called only once.public final void sendMessageToAllNeighbors(Message m)
getEdges()
and may be called only once.m
- The message to send.public final void sendMessageTo(K target, Message m)
target
- The key (id) of the target vertex to message.m
- The message.public final void setNewVertexValue(VV newValue)
This should be called at most once per ComputeFunction.
newValue
- The new vertex value.public final int getSuperstepNumber()
public final <T extends Aggregator<?>> T getIterationAggregator(String name)
name
- The name of the aggregator.null
, if no aggregator was
registered.public final <T extends Value> T getPreviousIterationAggregate(String name)
name
- The name of the aggregator.public final <T> Collection<T> getBroadcastSet(String name)
VertexCentricConfiguration.addBroadcastSet(String, DataSet)
.name
- The name under which the broadcast set is registered.Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.