Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1281#discussion_r42728398
--- Diff:
flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/spargel/MessagingFunction.java
---
@@ -129,24 +133,43 @@ public void postSuperstep() throws Exception {}
}
/**
- * Sends the given message to all vertices that are targets of an
outgoing edge of the changed vertex.
+ * Sends the given message to all vertices that are targets of an edge
of the changed vertex.
* This method is mutually exclusive to the method {@link #getEdges()}
and may be called only once.
+ * <p>
+ * If the {@link EdgeDirection} is OUT (default), the message will be
sent to out-neighbors.
+ * If the {@link EdgeDirection} is IN, the message will be sent to
in-neighbors.
+ * If the {@link EdgeDirection} is ALL, the message will be sent to all
neighbors.
*
* @param m The message to send.
*/
public void sendMessageToAllNeighbors(Message m) {
if (edgesUsed) {
- throw new IllegalStateException("Can use either
'getEdges()' or 'sendMessageToAllTargets()' exactly once.");
+ throw new IllegalStateException("Can use either
'getEdges()' or 'sendMessageToAllNeighbors()'"
+ + "exactly once.");
}
edgesUsed = true;
-
outValue.f1 = m;
while (edges.hasNext()) {
Tuple next = (Tuple) edges.next();
- K k = next.getField(1);
- outValue.f0 = k;
+
+ if (getDirection().equals(EdgeDirection.OUT)) {
+ outValue.f0 = next.getField(1);
+ }
+ else if (getDirection().equals(EdgeDirection.IN)) {
+ outValue.f0 = next.getField(0);
--- End diff --
I see, thanks for explaining.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---