Github user vasia commented on a diff in the pull request: https://github.com/apache/flink/pull/576#discussion_r28594561 --- Diff: docs/gelly_guide.md --- @@ -316,28 +327,49 @@ DataSet<Tuple2<Long, Long>> verticesWithSum = graph.reduceOnNeighbors( new SumValues(), EdgeDirection.IN); // user-defined function to sum the neighbor values -static final class SumValues implements NeighborsFunction<Long, Long, Double, Tuple2<Long, Long>> { - - public Tuple2<Long, Long> iterateNeighbors(Iterable<Tuple3<Long, Edge<Long, Double>, - Vertex<Long, Long>>> neighbors) { - - long sum = 0; - long vertexId = -1; +static final class SumValues implements ReduceNeighborsFunction<Long, Long, Double> { - for (Tuple3<Long, Edge<Long, Double>, Vertex<Long, Long>> neighbor : neighbors) { - vertexId = neighbor.f0; - sum += neighbor.f2.getValue(); - } - return new Tuple2<Long, Long>(vertexId, sum); - } + public Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> reduceNeighbors(Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> firstNeighbor, + Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>> secondNeighbor) { + + long sum = firstNeighbor.f2.getValue() + secondNeighbor.f2.getValue(); + return new Tuple3<Long, Edge<Long, Long>, Vertex<Long, Long>>(firstNeighbor.f0, firstNeighbor.f1, + new Vertex<Long, Long>(firstNeighbor.f0, sum)); + } } {% endhighlight %} <p class="text-center"> - <img alt="reduseOnNeighbors Example" width="70%" src="img/gelly-reduceOnNeighbors.png"/> + <img alt="reduceOnNeighbors Example" width="70%" src="img/gelly-reduceOnNeighbors.png"/> --- End diff -- good catch :+1:
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---