K
- The type of the vertex key (the vertex identifier).VV
- The type of the vertex value (the state of the vertex).Message
- The type of the message sent between vertices along the edges.EV
- The type of the values that are associated with the edges.public abstract class ScatterFunction<K,VV,Message,EV> extends Object implements Serializable
ScatterGatherIteration
.Constructor and Description |
---|
ScatterFunction() |
Modifier and Type | Method and Description |
---|---|
<T> Collection<T> |
getBroadcastSet(String name)
Gets the broadcast data set registered under the given name.
|
EdgeDirection |
getDirection()
Retrieves the edge direction in which messages are propagated in the scatter-gather iteration.
|
Iterable<Edge<K,EV>> |
getEdges()
Gets an
Iterable with all edges. |
long |
getInDegree()
Retrieves the vertex in-degree (number of in-coming edges).
|
<T extends Aggregator<?>> |
getIterationAggregator(String name)
Gets the iteration aggregator registered under the given name.
|
long |
getNumberOfVertices()
Retrieves the number of vertices in the graph.
|
long |
getOutDegree()
Retrieve the vertex out-degree (number of out-going edges).
|
<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 scatter function has been invoked for each vertex.
|
void |
preSuperstep()
This method is executed once per superstep before the scatter function is invoked for each vertex.
|
abstract void |
sendMessages(Vertex<K,VV> vertex)
This method is invoked once per superstep for each vertex that was changed in that superstep.
|
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 are targets of an edge of the changed vertex.
|
public long getNumberOfVertices()
IterationConfiguration.setOptNumVertices(boolean)
option has been set; -1 otherwise.public EdgeDirection getDirection()
EdgeDirection
public abstract void sendMessages(Vertex<K,VV> vertex) throws Exception
vertex
- The vertex that was changed.Exception
- The computation may throw exceptions, which causes the superstep to fail.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 Iterable<Edge<K,EV>> getEdges()
Iterable
with all edges. This method is mutually exclusive with
sendMessageToAllNeighbors(Object)
and may be called only once.
If the EdgeDirection
is OUT (default), then this iterator contains outgoing edges.
If the EdgeDirection
is IN, then this iterator contains incoming edges.
If the EdgeDirection
is ALL, then this iterator contains both outgoing and incoming edges.
public void sendMessageToAllNeighbors(Message m)
getEdges()
and may be called only once.
If the EdgeDirection
is OUT (default), the message will be sent to out-neighbors.
If the EdgeDirection
is IN, the message will be sent to in-neighbors.
If the EdgeDirection
is ALL, the message will be sent to all neighbors.
m
- The message to send.public void sendMessageTo(K target, Message m)
target
- The key (id) of the target vertex to message.m
- The message.public int getSuperstepNumber()
public <T extends Aggregator<?>> T getIterationAggregator(String name)
name
- The name of the aggregator.public <T extends Value> T getPreviousIterationAggregate(String name)
name
- The name of the aggregator.public <T> Collection<T> getBroadcastSet(String name)
ScatterGatherConfiguration.addBroadcastSetForScatterFunction(String, org.apache.flink.api.java.DataSet)
.name
- The name under which the broadcast set is registered.public long getInDegree()
public long getOutDegree()
Copyright © 2014–2019 The Apache Software Foundation. All rights reserved.