Github user vasia commented on a diff in the pull request:

    https://github.com/apache/flink/pull/462#discussion_r26009469
  
    --- Diff: 
flink-staging/flink-gelly/src/main/java/org/apache/flink/graph/example/GraphMetrics.java
 ---
    @@ -63,17 +63,17 @@ public static void main(String[] args) throws Exception 
{
                                .getRandomEdges(env, NUM_VERTICES), env);
                
                /** get the number of vertices **/
    -           DataSet<Integer> numVertices = graph.numberOfVertices();
    +           long numVertices = graph.numberOfVertices();
                
                /** get the number of edges **/
    -           DataSet<Integer> numEdges = graph.numberOfEdges();
    +           long numEdges = graph.numberOfEdges();
                
                /** compute the average node degree **/
                DataSet<Tuple2<Long, Long>> verticesWithDegrees = 
graph.getDegrees();
     
                DataSet<Double> avgNodeDegree = verticesWithDegrees
                                .aggregate(Aggregations.SUM, 1).map(new 
AvgNodeDegreeMapper())
    -                           .withBroadcastSet(numVertices, 
"numberOfVertices");
    +                           
.withBroadcastSet(env.fromElements(numVertices), "numberOfVertices");
    --- End diff --
    
    Since `numVertices` is a single value, you can just pass it as an argument 
to `AvgNodeDegreeMapper()`. No need for a broadcast variable.


---
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.
---

Reply via email to