[GitHub] flink pull request: [FLINK-2827] Closing FileInputStream through t...
Github user ssaumitra commented on the pull request: https://github.com/apache/flink/pull/1276#issuecomment-150665625 @StephanEwen I have made the changes and rebased on master. Kindly review. --- 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. ---
[GitHub] flink pull request: [FLINK-2827] Closing FileInputStream in finall...
Github user ssaumitra commented on the pull request: https://github.com/apache/flink/pull/1276#issuecomment-149862453 I just observed that Flink has already dropped Java 6 support. try with resources is the best possible approach then. I will amend my commit. --- 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. ---
[GitHub] flink pull request: [FLINK-2827] Closing FileInputStream in finall...
GitHub user ssaumitra opened a pull request: https://github.com/apache/flink/pull/1276 [FLINK-2827] Closing FileInputStream in finally block to avoid unused open stream. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ssaumitra/flink FLINK-2254 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/1276.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 #1276 commit 4a16423d24f73533674b555e9fdf26b2b0423182 Author: Saumitra Shahapure <saumitra.offic...@gmail.com> Date: 2015-10-20T17:28:31Z [FLINK-2827] Closing FileInputStream in finally block to avoid unused open stream. --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on a diff in the pull request: https://github.com/apache/flink/pull/1250#discussion_r42108353 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/TriangleEnumerator.java --- @@ -0,0 +1,347 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.library; + +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.common.functions.ReduceFunction; +import org.apache.flink.api.common.functions.FlatMapFunction; +import org.apache.flink.api.common.functions.JoinFunction; +import org.apache.flink.api.common.functions.GroupReduceFunction; +import org.apache.flink.api.common.operators.Order; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.functions.FunctionAnnotation; +import org.apache.flink.api.java.tuple.Tuple3; +import org.apache.flink.api.java.tuple.Tuple4; +import org.apache.flink.graph.Edge; +import org.apache.flink.graph.Graph; +import org.apache.flink.graph.GraphAlgorithm; +import org.apache.flink.graph.example.utils.TriangleCountData; +import org.apache.flink.types.NullValue; +import org.apache.flink.util.Collector; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +/** + * This function returns number of triangles present in the input graph. + * A triangle consists of three edges that connect three vertices with each other. + * + * + * The basic algorithm works as follows: + * It groups all edges that share a common vertex and builds triads, i.e., triples of vertices + * that are connected by two edges. Finally, all triads are filtered for which no third edge exists + * that closes the triangle. + * + * + * For a group of n edges that share a common vertex, the number of built triads is quadratic ((n*(n-1))/2). + * Therefore, an optimization of the algorithm is to group edges on the vertex with the smaller output degree to + * reduce the number of triads. + * This implementation extends the basic algorithm by computing output degrees of edge vertices and + * grouping on edges on the vertex with the smaller degree. + */ + +public class TriangleEnumerator, VV, EV> implements GraphAlgorithm<K, VV, EV, DataSet<Tuple3<K,K,K>>> { + @Override + public DataSet<Tuple3<K,K,K>> run(Graph<K, VV, EV> input) throws Exception { + + DataSet<Edge<K, EV>> edges = input.getEdges(); + + // annotate edges with degrees + DataSet<EdgeWithDegrees> edgesWithDegrees = edges.flatMap(new EdgeDuplicator<K, EV>()) + .groupBy(0).sortGroup(1, Order.ASCENDING).reduceGroup(new DegreeCounter<K, EV>()) + .groupBy(EdgeWithDegrees.V1, EdgeWithDegrees.V2).reduce(new DegreeJoiner()); + + // project edges by degrees + DataSet<Edge<K, NullValue>> edgesByDegree = edgesWithDegrees.map(new EdgeByDegreeProjector()); + // project edges by vertex id + DataSet<Edge<K, NullValue>> edgesById = edgesByDegree.map(new EdgeByIdProjector()); + + DataSet<Tuple3<K,K,K>> triangles = edgesByDegree + // build triads + .groupBy(EdgeWithDegrees.V1).sortGroup(EdgeWithDegrees.V2, Order.ASCENDING) + .reduceGroup(new TriadBuilder()) + // filter triads + .join(edgesById).where(Triad.V2, Triad.V3).equalTo(0, 1).with(new TriadFilter()); + + return triangles; + } + + /** +* Emits for an edge the original edge and its switched version. +*/ + private static final class EdgeDup
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on a diff in the pull request: https://github.com/apache/flink/pull/1250#discussion_r42153585 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/TriangleEnumerator.java --- @@ -0,0 +1,347 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.library; + +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.common.functions.ReduceFunction; +import org.apache.flink.api.common.functions.FlatMapFunction; +import org.apache.flink.api.common.functions.JoinFunction; +import org.apache.flink.api.common.functions.GroupReduceFunction; +import org.apache.flink.api.common.operators.Order; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.functions.FunctionAnnotation; +import org.apache.flink.api.java.tuple.Tuple3; +import org.apache.flink.api.java.tuple.Tuple4; +import org.apache.flink.graph.Edge; +import org.apache.flink.graph.Graph; +import org.apache.flink.graph.GraphAlgorithm; +import org.apache.flink.graph.example.utils.TriangleCountData; --- End diff -- My bad again :) --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on a diff in the pull request: https://github.com/apache/flink/pull/1250#discussion_r42153562 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/TriangleEnumerator.java --- @@ -0,0 +1,347 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.library; + +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.common.functions.ReduceFunction; +import org.apache.flink.api.common.functions.FlatMapFunction; +import org.apache.flink.api.common.functions.JoinFunction; +import org.apache.flink.api.common.functions.GroupReduceFunction; +import org.apache.flink.api.common.operators.Order; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; --- End diff -- My bad --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on a diff in the pull request: https://github.com/apache/flink/pull/1250#discussion_r42153539 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/example/utils/TriangleCountData.java --- @@ -20,10 +20,12 @@ import org.apache.flink.api.java.DataSet; import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.tuple.Tuple3; import org.apache.flink.graph.Edge; import org.apache.flink.types.NullValue; import java.util.ArrayList; +import java.util.Arrays; --- End diff -- My bad, I had to optimise them, --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on a diff in the pull request: https://github.com/apache/flink/pull/1250#discussion_r42153609 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/TriangleEnumerator.java --- @@ -0,0 +1,347 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.library; + +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.common.functions.ReduceFunction; +import org.apache.flink.api.common.functions.FlatMapFunction; +import org.apache.flink.api.common.functions.JoinFunction; +import org.apache.flink.api.common.functions.GroupReduceFunction; +import org.apache.flink.api.common.operators.Order; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.functions.FunctionAnnotation; +import org.apache.flink.api.java.tuple.Tuple3; +import org.apache.flink.api.java.tuple.Tuple4; +import org.apache.flink.graph.Edge; +import org.apache.flink.graph.Graph; +import org.apache.flink.graph.GraphAlgorithm; +import org.apache.flink.graph.example.utils.TriangleCountData; +import org.apache.flink.types.NullValue; +import org.apache.flink.util.Collector; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +/** + * This function returns number of triangles present in the input graph. --- End diff -- Corrected. --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on the pull request: https://github.com/apache/flink/pull/1250#issuecomment-148486062 @vasia I have updated it. Please have a look. Also should I be worried about Travis build failure? Looks like it's failing on master too, --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on the pull request: https://github.com/apache/flink/pull/1250#issuecomment-147180010 Fir enough. I will make this change in my pull request then. Can you please edit the JIRA too? So that updated pull request and JIRA title stay relevant? --- 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. ---
[GitHub] flink pull request: [FLINK-2841] Correcting roadmap link to point ...
GitHub user ssaumitra opened a pull request: https://github.com/apache/flink/pull/1254 [FLINK-2841] Correcting roadmap link to point to confluence. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ssaumitra/flink FLINK_2841 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/1254.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 #1254 commit 632188dc9bb587fbe861faa4843b13b8fa654c82 Author: Saumitra Shahapure <saumitra.offic...@gmail.com> Date: 2015-10-11T20:32:54Z [FLINK-2841] Correcting roadmap link to point to confluence. --- 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. ---
[GitHub] flink pull request: [FLINK-2841] Correcting roadmap link to point ...
Github user ssaumitra commented on the pull request: https://github.com/apache/flink/pull/1254#issuecomment-147245999 Made the change. I have amended the past commit because it was kind-of incorrect. --- 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. ---
[GitHub] flink pull request: [FLINK-2841] Correcting roadmap link to point ...
Github user ssaumitra commented on the pull request: https://github.com/apache/flink/pull/1254#issuecomment-147244169 Oh, my bad, I thought Flink Roadmap is the only main page maintained for sub-projects too. Is this the correct one? https://cwiki.apache.org/confluence/display/FLINK/FlinkML%3A+Vision+and+Roadmap --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
GitHub user ssaumitra opened a pull request: https://github.com/apache/flink/pull/1250 [FLINK-2714] [Gelly] Copy triangle counting logic from EnumTrianglesOpt.java to Gelly library. Also reorganizing classes to use Gelly's Graph APIs. You can merge this pull request into a Git repository by running: $ git pull https://github.com/ssaumitra/flink FLINK_2714 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/1250.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 #1250 commit 7a8f24331bb2d0ad7b050745d832ba4ce777982e Author: Saumitra Shahapure <saumitra.offic...@gmail.com> Date: 2015-10-09T21:51:45Z [FLINK-2714] Copy triangle counting logic from EnumTrianglesOpt.java to Gelly library. Also reorganizing classes to use Gelly's Graph APIs. --- 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. ---
[GitHub] flink pull request: [FLINK-2714] [Gelly] Copy triangle counting lo...
Github user ssaumitra commented on a diff in the pull request: https://github.com/apache/flink/pull/1250#discussion_r41696647 --- Diff: flink-libraries/flink-gelly/src/main/java/org/apache/flink/graph/library/TriangleCounter.java --- @@ -0,0 +1,339 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.graph.library; + +import org.apache.flink.api.common.functions.MapFunction; +import org.apache.flink.api.common.functions.ReduceFunction; +import org.apache.flink.api.common.functions.FlatMapFunction; +import org.apache.flink.api.common.functions.JoinFunction; +import org.apache.flink.api.common.functions.GroupReduceFunction; +import org.apache.flink.api.common.operators.Order; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.functions.FunctionAnnotation; +import org.apache.flink.api.java.tuple.Tuple3; +import org.apache.flink.api.java.tuple.Tuple4; +import org.apache.flink.graph.Edge; +import org.apache.flink.graph.Graph; +import org.apache.flink.graph.GraphAlgorithm; +import org.apache.flink.types.NullValue; +import org.apache.flink.util.Collector; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + + +/** + * This function returns number of triangles present in the input graph. + * A triangle consists of three edges that connect three vertices with each other. + * + * + * The basic algorithm works as follows: + * It groups all edges that share a common vertex and builds triads, i.e., triples of vertices + * that are connected by two edges. Finally, all triads are filtered for which no third edge exists + * that closes the triangle. + * + * + * For a group of n edges that share a common vertex, the number of built triads is quadratic ((n*(n-1))/2). + * Therefore, an optimization of the algorithm is to group edges on the vertex with the smaller output degree to + * reduce the number of triads. + * This implementation extends the basic algorithm by computing output degrees of edge vertices and + * grouping on edges on the vertex with the smaller degree. + */ + +public class TriangleCounter, VV, EV> implements GraphAlgorithm<K, VV, EV, DataSet> { + @Override + public DataSet run(Graph<K, VV, EV> input) throws Exception { + + DataSet<Edge<K, EV>> edges = input.getEdges(); + + // annotate edges with degrees + DataSet<EdgeWithDegrees> edgesWithDegrees = edges.flatMap(new EdgeDuplicator<K, EV>()) + .groupBy(0).sortGroup(1, Order.ASCENDING).reduceGroup(new DegreeCounter<K, EV>()) + .groupBy(EdgeWithDegrees.V1, EdgeWithDegrees.V2).reduce(new DegreeJoiner()); + + // project edges by degrees + DataSet<Edge<K, NullValue>> edgesByDegree = edgesWithDegrees.map(new EdgeByDegreeProjector()); + // project edges by vertex id + DataSet<Edge<K, NullValue>> edgesById = edgesByDegree.map(new EdgeByIdProjector()); + + DataSet triangles = edgesByDegree + // build triads + .groupBy(EdgeWithDegrees.V1).sortGroup(EdgeWithDegrees.V2, Order.ASCENDING) + .reduceGroup(new TriadBuilder()) + // filter triads + .join(edgesById).where(Triad.V2, Triad.V3).equalTo(0, 1).with(new TriadFilter()); --- End diff -- Just FYI, vertices of Triad and edgesWithDegrees are referred with V1 and V2. And those of edges are referred with indices 0 and 1. IMHO, org.apache.flink.graph.Edge can also have static variables V1, V2 so that group operators are more readable. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If yo