[ 
https://issues.apache.org/jira/browse/FLINK-1632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14352282#comment-14352282
 ] 

ASF GitHub Bot commented on FLINK-1632:
---------------------------------------

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.


> Use DataSet's count() and collect() to simplify Gelly methods
> -------------------------------------------------------------
>
>                 Key: FLINK-1632
>                 URL: https://issues.apache.org/jira/browse/FLINK-1632
>             Project: Flink
>          Issue Type: Improvement
>          Components: Gelly
>    Affects Versions: 0.9
>            Reporter: Vasia Kalavri
>            Assignee: Andra Lungu
>            Priority: Minor
>              Labels: easyfix, starter
>
> The recently introduced count() and collect() methods of DataSet can be used 
> to simplify several Gelly methods. We can get rid of GraphUtils and also 
> simplify methods which return DataSets with single values, such as 
> numberOfVertices() and isWeaklyConnected().



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to