You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by andralungu <gi...@git.apache.org> on 2015/06/03 16:16:36 UTC

[GitHub] flink pull request: [FLINK-2149][gelly] Simplified Jaccard Example

GitHub user andralungu opened a pull request:

    https://github.com/apache/flink/pull/770

    [FLINK-2149][gelly] Simplified Jaccard Example

    This PR simplifies Gelly's Jaccard example by using the more efficient reduceOnNeighbors rather than groupReduceOnNeighbors. 

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/andralungu/flink jaccardImprovement

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/flink/pull/770.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #770
    
----
commit 0e189c6af9a5fb80b4999a60a431d60cf95944db
Author: andralungu <lu...@gmail.com>
Date:   2015-06-03T14:12:16Z

    [FLINK-2149][gelly] Simplified Jaccard Example

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2149][gelly] Simplified Jaccard Example

Posted by vasia <gi...@git.apache.org>.
Github user vasia commented on the pull request:

    https://github.com/apache/flink/pull/770#issuecomment-111760796
  
    +1 except the minor comment


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2149][gelly] Simplified Jaccard Example

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/770


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2149][gelly] Simplified Jaccard Example

Posted by andralungu <gi...@git.apache.org>.
Github user andralungu commented on the pull request:

    https://github.com/apache/flink/pull/770#issuecomment-111807874
  
    PR updated.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2149][gelly] Simplified Jaccard Example

Posted by andralungu <gi...@git.apache.org>.
Github user andralungu commented on the pull request:

    https://github.com/apache/flink/pull/770#issuecomment-113752297
  
    Meging...


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink pull request: [FLINK-2149][gelly] Simplified Jaccard Example

Posted by vasia <gi...@git.apache.org>.
Github user vasia commented on a diff in the pull request:

    https://github.com/apache/flink/pull/770#discussion_r32374939
  
    --- Diff: flink-staging/flink-gelly/src/main/java/org/apache/flink/graph/example/JaccardSimilarityMeasure.java ---
    @@ -66,34 +63,47 @@ public static void main(String [] args) throws Exception {
     
     		DataSet<Edge<Long, Double>> edges = getEdgesDataSet(env);
     
    -		Graph<Long, NullValue, Double> graph = Graph.fromDataSet(edges, env);
    +		Graph<Long, HashSet<Long>, Double> graph = Graph.fromDataSet(edges,
    +				new MapFunction<Long, HashSet<Long>>() {
     
    -		DataSet<Vertex<Long, HashSet<Long>>> verticesWithNeighbors =
    -				graph.groupReduceOnEdges(new GatherNeighbors(), EdgeDirection.ALL);
    +					@Override
    +					public HashSet<Long> map(Long id) throws Exception {
    +						HashSet<Long> neighbors = new HashSet<Long>();
    +						neighbors.add(id);
     
    -		Graph<Long, HashSet<Long>, Double> graphWithVertexValues = Graph.fromDataSet(verticesWithNeighbors, edges, env);
    +						return new HashSet<Long>(neighbors);
    +					}
    +				}, env);
     
    -		// the edge value will be the Jaccard similarity coefficient(number of common neighbors/ all neighbors)
    -		DataSet<Tuple3<Long, Long, Double>> edgesWithJaccardWeight = graphWithVertexValues.getTriplets()
    -				.map(new WeighEdgesMapper());
    +		// create the set of neighbors
    +		DataSet<Tuple2<Long, HashSet<Long>>> computedNeighbors =
    +				graph.reduceOnNeighbors(new GatherNeighbors(), EdgeDirection.ALL);
     
    -		DataSet<Edge<Long, Double>> result = graphWithVertexValues.joinWithEdges(edgesWithJaccardWeight,
    -				new MapFunction<Tuple2<Double, Double>, Double>() {
    +		// join with the vertices to update the node values
    +		DataSet<Vertex<Long, HashSet<Long>>> verticesWithNeighbors =
    +				graph.joinWithVertices(computedNeighbors, new MapFunction<Tuple2<HashSet<Long>, HashSet<Long>>,
    +						HashSet<Long>>() {
     
     					@Override
    -					public Double map(Tuple2<Double, Double> value) throws Exception {
    -						return value.f1;
    +					public HashSet<Long> map(Tuple2<HashSet<Long>, HashSet<Long>> tuple2) throws Exception {
    +						return tuple2.f1;
     					}
    -				}).getEdges();
    +				}).getVertices();
    +
    +		Graph<Long, HashSet<Long>, Double> graphWithVertexValues = Graph.fromDataSet(verticesWithNeighbors, edges, env);
    --- End diff --
    
    joinWithVertices can give you the Graph directly :)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---