[hotfix] [gelly] Indent Java with tabs not spaces This PR also applies IntelliJ's "reformat code" using the unofficial Flink-style configuration.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/cb282067 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/cb282067 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/cb282067 Branch: refs/heads/master Commit: cb282067517ed721858e5c898abbbf59a2fbafef Parents: 53716a4 Author: Greg Hogan <[email protected]> Authored: Tue Jan 17 15:01:17 2017 -0500 Committer: Greg Hogan <[email protected]> Committed: Tue Jan 17 15:38:25 2017 -0500 ---------------------------------------------------------------------- .../graph/library/CommunityDetectionITCase.java | 14 +- .../graph/library/LabelPropagationITCase.java | 16 +- .../flink/graph/library/PageRankITCase.java | 50 +- .../flink/graph/test/GatherSumApplyITCase.java | 32 +- .../SingleSourceShortestPathsITCase.java | 94 +-- .../test/GatherSumApplyConfigurationITCase.java | 90 ++- .../test/ScatterGatherConfigurationITCase.java | 262 ++++---- .../graph/test/operations/DegreesITCase.java | 201 ++++--- .../test/operations/FromCollectionITCase.java | 109 ++-- .../test/operations/GraphCreationITCase.java | 143 ++--- .../GraphCreationWithMapperITCase.java | 85 ++- .../test/operations/GraphOperationsITCase.java | 235 ++++---- .../test/operations/JoinWithEdgesITCase.java | 593 +++++++++---------- .../test/operations/JoinWithVerticesITCase.java | 185 +++--- .../graph/test/operations/MapEdgesITCase.java | 118 ++-- .../test/operations/MapVerticesITCase.java | 91 ++- .../operations/ReduceOnEdgesMethodsITCase.java | 345 +++++------ .../ReduceOnNeighborMethodsITCase.java | 388 ++++++------ 18 files changed, 1511 insertions(+), 1540 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/CommunityDetectionITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/CommunityDetectionITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/CommunityDetectionITCase.java index cd8af9b..c37d1ed 100644 --- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/CommunityDetectionITCase.java +++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/CommunityDetectionITCase.java @@ -47,10 +47,10 @@ public class CommunityDetectionITCase extends MultipleProgramsTestBase { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Double> inputGraph = Graph.fromDataSet( - CommunityDetectionData.getSimpleEdgeDataSet(env), new InitLabels(), env); + CommunityDetectionData.getSimpleEdgeDataSet(env), new InitLabels(), env); - List<Vertex<Long, Long>> result = inputGraph.run(new CommunityDetection<Long>(1, CommunityDetectionData.DELTA)) - .getVertices().collect(); + List<Vertex<Long, Long>> result = inputGraph.run(new CommunityDetection<Long>(1, CommunityDetectionData.DELTA)) + .getVertices().collect(); expected = CommunityDetectionData.COMMUNITIES_SINGLE_ITERATION; compareResultAsTuples(result, expected); @@ -63,16 +63,16 @@ public class CommunityDetectionITCase extends MultipleProgramsTestBase { */ ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Double> inputGraph = Graph.fromDataSet( - CommunityDetectionData.getTieEdgeDataSet(env), new InitLabels(), env); + CommunityDetectionData.getTieEdgeDataSet(env), new InitLabels(), env); - List<Vertex<Long, Long>> result = inputGraph.run(new CommunityDetection<Long>(1, CommunityDetectionData.DELTA)) - .getVertices().collect(); + List<Vertex<Long, Long>> result = inputGraph.run(new CommunityDetection<Long>(1, CommunityDetectionData.DELTA)) + .getVertices().collect(); expected = CommunityDetectionData.COMMUNITIES_WITH_TIE; compareResultAsTuples(result, expected); } @SuppressWarnings("serial") - private static final class InitLabels implements MapFunction<Long, Long>{ + private static final class InitLabels implements MapFunction<Long, Long> { public Long map(Long id) { return id; http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/LabelPropagationITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/LabelPropagationITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/LabelPropagationITCase.java index 8b9234b..e6ba794 100644 --- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/LabelPropagationITCase.java +++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/LabelPropagationITCase.java @@ -33,11 +33,11 @@ import java.util.List; @RunWith(Parameterized.class) public class LabelPropagationITCase extends MultipleProgramsTestBase { - public LabelPropagationITCase(TestExecutionMode mode){ + public LabelPropagationITCase(TestExecutionMode mode) { super(mode); } - private String expectedResult; + private String expectedResult; @Test public void testSingleIteration() throws Exception { @@ -47,10 +47,10 @@ public class LabelPropagationITCase extends MultipleProgramsTestBase { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, NullValue> inputGraph = Graph.fromDataSet( - LabelPropagationData.getDefaultVertexSet(env), - LabelPropagationData.getDefaultEdgeDataSet(env), env); + LabelPropagationData.getDefaultVertexSet(env), + LabelPropagationData.getDefaultEdgeDataSet(env), env); - List<Vertex<Long, Long>> result = inputGraph + List<Vertex<Long, Long>> result = inputGraph .run(new LabelPropagation<Long, Long, NullValue>(1)) .collect(); @@ -66,10 +66,10 @@ public class LabelPropagationITCase extends MultipleProgramsTestBase { ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, NullValue> inputGraph = Graph.fromDataSet( - LabelPropagationData.getTieVertexSet(env), - LabelPropagationData.getTieEdgeDataSet(env), env); + LabelPropagationData.getTieVertexSet(env), + LabelPropagationData.getTieEdgeDataSet(env), env); - List<Vertex<Long, Long>> result = inputGraph + List<Vertex<Long, Long>> result = inputGraph .run(new LabelPropagation<Long, Long, NullValue>(1)) .collect(); http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/PageRankITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/PageRankITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/PageRankITCase.java index e3e8f08..25a3e3f 100644 --- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/PageRankITCase.java +++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/library/PageRankITCase.java @@ -35,7 +35,7 @@ import java.util.List; @RunWith(Parameterized.class) public class PageRankITCase extends MultipleProgramsTestBase { - public PageRankITCase(TestExecutionMode mode){ + public PageRankITCase(TestExecutionMode mode) { super(mode); } @@ -44,12 +44,12 @@ public class PageRankITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Double, Double> inputGraph = Graph.fromDataSet( - PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); + PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); - List<Vertex<Long, Double>> result = inputGraph.run(new PageRank<Long>(0.85, 3)) - .collect(); - - compareWithDelta(result, 0.01); + List<Vertex<Long, Double>> result = inputGraph.run(new PageRank<Long>(0.85, 3)) + .collect(); + + compareWithDelta(result, 0.01); } @Test @@ -57,12 +57,12 @@ public class PageRankITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Double, Double> inputGraph = Graph.fromDataSet( - PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); + PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); + + List<Vertex<Long, Double>> result = inputGraph.run(new GSAPageRank<Long>(0.85, 3)) + .collect(); - List<Vertex<Long, Double>> result = inputGraph.run(new GSAPageRank<Long>(0.85, 3)) - .collect(); - - compareWithDelta(result, 0.01); + compareWithDelta(result, 0.01); } @Test @@ -70,12 +70,12 @@ public class PageRankITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Double, Double> inputGraph = Graph.fromDataSet( - PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); + PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); - List<Vertex<Long, Double>> result = inputGraph.run(new PageRank<Long>(0.85, 3)) - .collect(); + List<Vertex<Long, Double>> result = inputGraph.run(new PageRank<Long>(0.85, 3)) + .collect(); - compareWithDelta(result, 0.01); + compareWithDelta(result, 0.01); } @Test @@ -83,20 +83,20 @@ public class PageRankITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Double, Double> inputGraph = Graph.fromDataSet( - PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); + PageRankData.getDefaultEdgeDataSet(env), new InitMapper(), env); - List<Vertex<Long, Double>> result = inputGraph.run(new GSAPageRank<Long>(0.85, 3)) - .collect(); - - compareWithDelta(result, 0.01); + List<Vertex<Long, Double>> result = inputGraph.run(new GSAPageRank<Long>(0.85, 3)) + .collect(); + + compareWithDelta(result, 0.01); } private void compareWithDelta(List<Vertex<Long, Double>> result, double delta) { String resultString = ""; - for (Vertex<Long, Double> v : result) { - resultString += v.f0.toString() + "," + v.f1.toString() +"\n"; - } + for (Vertex<Long, Double> v : result) { + resultString += v.f0.toString() + "," + v.f1.toString() + "\n"; + } String expectedResult = PageRankData.RANKS_AFTER_3_ITERATIONS; String[] expected = expectedResult.isEmpty() ? new String[0] : expectedResult.split("\n"); @@ -104,7 +104,7 @@ public class PageRankITCase extends MultipleProgramsTestBase { String[] resultArray = resultString.isEmpty() ? new String[0] : resultString.split("\n"); Arrays.sort(expected); - Arrays.sort(resultArray); + Arrays.sort(resultArray); for (int i = 0; i < expected.length; i++) { String[] expectedFields = expected[i].split(","); @@ -114,7 +114,7 @@ public class PageRankITCase extends MultipleProgramsTestBase { double resultPayLoad = Double.parseDouble(resultFields[1]); Assert.assertTrue("Values differ by more than the permissible delta", - Math.abs(expectedPayLoad - resultPayLoad) < delta); + Math.abs(expectedPayLoad - resultPayLoad) < delta); } } http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/GatherSumApplyITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/GatherSumApplyITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/GatherSumApplyITCase.java index cf960b4..5ce2e28 100644 --- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/GatherSumApplyITCase.java +++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/GatherSumApplyITCase.java @@ -37,7 +37,7 @@ import java.util.List; @RunWith(Parameterized.class) public class GatherSumApplyITCase extends MultipleProgramsTestBase { - public GatherSumApplyITCase(TestExecutionMode mode){ + public GatherSumApplyITCase(TestExecutionMode mode) { super(mode); } @@ -52,16 +52,16 @@ public class GatherSumApplyITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, NullValue> inputGraph = Graph.fromDataSet( - ConnectedComponentsDefaultData.getDefaultEdgeDataSet(env), - new InitMapperCC(), env); + ConnectedComponentsDefaultData.getDefaultEdgeDataSet(env), + new InitMapperCC(), env); - List<Vertex<Long, Long>> result = inputGraph.run( - new GSAConnectedComponents<Long, Long, NullValue>(16)).collect(); + List<Vertex<Long, Long>> result = inputGraph.run( + new GSAConnectedComponents<Long, Long, NullValue>(16)).collect(); expectedResult = "1,1\n" + - "2,1\n" + - "3,1\n" + - "4,1\n"; + "2,1\n" + + "3,1\n" + + "4,1\n"; compareResultAsTuples(result, expectedResult); } @@ -75,17 +75,17 @@ public class GatherSumApplyITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, NullValue, Double> inputGraph = Graph.fromDataSet( - SingleSourceShortestPathsData.getDefaultEdgeDataSet(env), - new InitMapperSSSP(), env); + SingleSourceShortestPathsData.getDefaultEdgeDataSet(env), + new InitMapperSSSP(), env); - List<Vertex<Long, Double>> result = inputGraph.run( - new GSASingleSourceShortestPaths<Long, NullValue>(1L, 16)).collect(); + List<Vertex<Long, Double>> result = inputGraph.run( + new GSASingleSourceShortestPaths<Long, NullValue>(1L, 16)).collect(); expectedResult = "1,0.0\n" + - "2,12.0\n" + - "3,13.0\n" + - "4,47.0\n" + - "5,48.0\n"; + "2,12.0\n" + + "3,13.0\n" + + "4,47.0\n" + + "5,48.0\n"; compareResultAsTuples(result, expectedResult); } http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/examples/SingleSourceShortestPathsITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/examples/SingleSourceShortestPathsITCase.java b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/examples/SingleSourceShortestPathsITCase.java index 9019d0b..2fd8812 100644 --- a/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/examples/SingleSourceShortestPathsITCase.java +++ b/flink-libraries/flink-gelly-examples/src/test/java/org/apache/flink/graph/test/examples/SingleSourceShortestPathsITCase.java @@ -40,51 +40,51 @@ import java.io.File; @RunWith(Parameterized.class) public class SingleSourceShortestPathsITCase extends MultipleProgramsTestBase { - private String edgesPath; - - private String resultPath; - - private String expected; - - @Rule - public TemporaryFolder tempFolder = new TemporaryFolder(); - - public SingleSourceShortestPathsITCase(TestExecutionMode mode) { - super(mode); - } - - @Before - public void before() throws Exception { - resultPath = tempFolder.newFile().toURI().toString(); - - File edgesFile = tempFolder.newFile(); - Files.write(SingleSourceShortestPathsData.EDGES, edgesFile, Charsets.UTF_8); - edgesPath = edgesFile.toURI().toString(); - } - - @Test - public void testSSSPExample() throws Exception { - SingleSourceShortestPaths.main(new String[]{SingleSourceShortestPathsData.SRC_VERTEX_ID + "", - edgesPath, resultPath, 10 + ""}); - expected = SingleSourceShortestPathsData.RESULTED_SINGLE_SOURCE_SHORTEST_PATHS; - } - - @Test - public void testGSASSSPExample() throws Exception { - GSASingleSourceShortestPaths.main(new String[]{SingleSourceShortestPathsData.SRC_VERTEX_ID + "", - edgesPath, resultPath, 10 + ""}); - expected = SingleSourceShortestPathsData.RESULTED_SINGLE_SOURCE_SHORTEST_PATHS; - } - - @Test - public void testPregelSSSPExample() throws Exception { - PregelSSSP.main(new String[]{SingleSourceShortestPathsData.SRC_VERTEX_ID + "", - edgesPath, resultPath, 10 + ""}); - expected = SingleSourceShortestPathsData.RESULTED_SINGLE_SOURCE_SHORTEST_PATHS; - } - - @After - public void after() throws Exception { - TestBaseUtils.compareResultsByLinesInMemory(expected, resultPath); - } + private String edgesPath; + + private String resultPath; + + private String expected; + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + public SingleSourceShortestPathsITCase(TestExecutionMode mode) { + super(mode); + } + + @Before + public void before() throws Exception { + resultPath = tempFolder.newFile().toURI().toString(); + + File edgesFile = tempFolder.newFile(); + Files.write(SingleSourceShortestPathsData.EDGES, edgesFile, Charsets.UTF_8); + edgesPath = edgesFile.toURI().toString(); + } + + @Test + public void testSSSPExample() throws Exception { + SingleSourceShortestPaths.main(new String[]{ SingleSourceShortestPathsData.SRC_VERTEX_ID + "", + edgesPath, resultPath, 10 + "" }); + expected = SingleSourceShortestPathsData.RESULTED_SINGLE_SOURCE_SHORTEST_PATHS; + } + + @Test + public void testGSASSSPExample() throws Exception { + GSASingleSourceShortestPaths.main(new String[]{ SingleSourceShortestPathsData.SRC_VERTEX_ID + "", + edgesPath, resultPath, 10 + "" }); + expected = SingleSourceShortestPathsData.RESULTED_SINGLE_SOURCE_SHORTEST_PATHS; + } + + @Test + public void testPregelSSSPExample() throws Exception { + PregelSSSP.main(new String[]{ SingleSourceShortestPathsData.SRC_VERTEX_ID + "", + edgesPath, resultPath, 10 + "" }); + expected = SingleSourceShortestPathsData.RESULTED_SINGLE_SOURCE_SHORTEST_PATHS; + } + + @After + public void after() throws Exception { + TestBaseUtils.compareResultsByLinesInMemory(expected, resultPath); + } } http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/GatherSumApplyConfigurationITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/GatherSumApplyConfigurationITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/GatherSumApplyConfigurationITCase.java index 98ecf16..183522d 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/GatherSumApplyConfigurationITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/GatherSumApplyConfigurationITCase.java @@ -59,7 +59,7 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env).mapVertices(new AssignOneMapper()); + TestGraphUtils.getLongLongEdges(), env).mapVertices(new AssignOneMapper()); // create the configuration object GSAConfiguration parameters = new GSAConfiguration(); @@ -71,31 +71,30 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase parameters.setOptNumVertices(true); Graph<Long, Long, Long> res = graph.runGatherSumApplyIteration(new Gather(), new Sum(), - new Apply(), 10, parameters); + new Apply(), 10, parameters); - DataSet<Vertex<Long, Long>> data = res.getVertices(); - List<Vertex<Long, Long>> result= data.collect(); + DataSet<Vertex<Long, Long>> data = res.getVertices(); + List<Vertex<Long, Long>> result = data.collect(); expectedResult = "1,11\n" + - "2,11\n" + - "3,11\n" + - "4,11\n" + - "5,11"; - + "2,11\n" + + "3,11\n" + + "4,11\n" + + "5,11"; + compareResultAsTuples(result, expectedResult); } @Test public void testIterationConfiguration() throws Exception { - /* * Test name, parallelism and solutionSetUnmanaged parameters */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); GatherSumApplyIteration<Long, Long, Long, Long> iteration = GatherSumApplyIteration - .withEdges(TestGraphUtils.getLongLongEdgeData(env), new DummyGather(), - new DummySum(), new DummyApply(), 10); + .withEdges(TestGraphUtils.getLongLongEdgeData(env), new DummyGather(), + new DummySum(), new DummyApply(), 10); GSAConfiguration parameters = new GSAConfiguration(); parameters.setName("gelly iteration"); @@ -109,20 +108,19 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase Assert.assertEquals(true, iteration.getIterationConfiguration().isSolutionSetUnmanagedMemory()); DataSet<Vertex<Long, Long>> data = TestGraphUtils.getLongLongVertexData(env).runOperation(iteration); - List<Vertex<Long, Long>> result= data.collect(); - + List<Vertex<Long, Long>> result = data.collect(); + expectedResult = "1,11\n" + - "2,12\n" + - "3,13\n" + - "4,14\n" + - "5,15"; - + "2,12\n" + + "3,13\n" + + "4,14\n" + + "5,15"; + compareResultAsTuples(result, expectedResult); } @Test public void testIterationDefaultDirection() throws Exception { - /* * Test that if no direction parameter is given, the iteration works as before * (i.e. it gathers information from the IN edges and neighbors and the information is calculated for an OUT edge @@ -137,27 +135,26 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase edges.remove(0); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), edges, env) - .mapVertices(new GatherSumApplyConfigurationITCase.InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), edges, env) + .mapVertices(new GatherSumApplyConfigurationITCase.InitialiseHashSetMapper()); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph.runGatherSumApplyIteration( new GetReachableVertices(), new FindAllReachableVertices(), new UpdateReachableVertices(), 4) - .getVertices(); + .getVertices(); List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[1, 2, 3, 4, 5]\n" - +"2,[2]\n" - +"3,[1, 2, 3, 4, 5]\n" - +"4,[1, 2, 3, 4, 5]\n" - +"5,[1, 2, 3, 4, 5]\n"; + + "2,[2]\n" + + "3,[1, 2, 3, 4, 5]\n" + + "4,[1, 2, 3, 4, 5]\n" + + "5,[1, 2, 3, 4, 5]\n"; compareResultAsTuples(result, expectedResult); } @Test public void testIterationDirectionIN() throws Exception { - /* * Test that if the direction parameter IN is given, the iteration works as expected * (i.e. it gathers information from the OUT edges and neighbors and the information is calculated for an IN edge @@ -175,27 +172,26 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase edges.remove(0); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), edges, env) - .mapVertices(new GatherSumApplyConfigurationITCase.InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), edges, env) + .mapVertices(new GatherSumApplyConfigurationITCase.InitialiseHashSetMapper()); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph.runGatherSumApplyIteration( new GetReachableVertices(), new FindAllReachableVertices(), new UpdateReachableVertices(), 4, - parameters) - .getVertices(); + parameters) + .getVertices(); List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[1, 3, 4, 5]\n" - +"2,[1, 2, 3, 4, 5]\n" - +"3,[1, 3, 4, 5]\n" - +"4,[1, 3, 4, 5]\n" - +"5,[1, 3, 4, 5]\n"; + + "2,[1, 2, 3, 4, 5]\n" + + "3,[1, 3, 4, 5]\n" + + "4,[1, 3, 4, 5]\n" + + "5,[1, 3, 4, 5]\n"; compareResultAsTuples(result, expectedResult); } @Test public void testIterationDirectionALL() throws Exception { - /* * Test that if the direction parameter OUT is given, the iteration works as expected * (i.e. it gathers information from both IN and OUT edges and neighbors @@ -212,21 +208,21 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase edges.remove(0); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), edges, env) - .mapVertices(new GatherSumApplyConfigurationITCase.InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), edges, env) + .mapVertices(new GatherSumApplyConfigurationITCase.InitialiseHashSetMapper()); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph.runGatherSumApplyIteration( new GetReachableVertices(), new FindAllReachableVertices(), new UpdateReachableVertices(), 4, parameters) - .getVertices(); + .getVertices(); List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[1, 2, 3, 4, 5]\n" - +"2,[1, 2, 3, 4, 5]\n" - +"3,[1, 2, 3, 4, 5]\n" - +"4,[1, 2, 3, 4, 5]\n" - +"5,[1, 2, 3, 4, 5]\n"; + + "2,[1, 2, 3, 4, 5]\n" + + "3,[1, 2, 3, 4, 5]\n" + + "4,[1, 2, 3, 4, 5]\n" + + "5,[1, 2, 3, 4, 5]\n"; compareResultAsTuples(result, expectedResult); } @@ -246,7 +242,7 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase // test aggregator if (getSuperstepNumber() == 2) { - long aggrValue = ((LongValue)getPreviousIterationAggregate("superstepAggregator")).getValue(); + long aggrValue = ((LongValue) getPreviousIterationAggregate("superstepAggregator")).getValue(); Assert.assertEquals(7, aggrValue); } @@ -381,7 +377,7 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase private static final class FindAllReachableVertices extends SumFunction<HashSet<Long>, Long, HashSet<Long>> { @Override public HashSet<Long> sum(HashSet<Long> newSet, HashSet<Long> currentSet) { - for(Long l : newSet) { + for (Long l : newSet) { currentSet.add(l); } return currentSet; @@ -394,7 +390,7 @@ public class GatherSumApplyConfigurationITCase extends MultipleProgramsTestBase @Override public void apply(HashSet<Long> newValue, HashSet<Long> currentValue) { newValue.addAll(currentValue); - if(newValue.size()>currentValue.size()) { + if (newValue.size() > currentValue.size()) { setResult(newValue); } } http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/ScatterGatherConfigurationITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/ScatterGatherConfigurationITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/ScatterGatherConfigurationITCase.java index 9100883..3c091a9 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/ScatterGatherConfigurationITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/ScatterGatherConfigurationITCase.java @@ -46,11 +46,11 @@ import java.util.List; @RunWith(Parameterized.class) public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { - public ScatterGatherConfigurationITCase(TestExecutionMode mode){ + public ScatterGatherConfigurationITCase(TestExecutionMode mode) { super(mode); } - private String expectedResult; + private String expectedResult; @Test public void testRunWithConfiguration() throws Exception { @@ -60,7 +60,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env).mapVertices(new AssignOneMapper()); + TestGraphUtils.getLongLongEdges(), env).mapVertices(new AssignOneMapper()); // create the configuration object ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -71,31 +71,30 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setOptNumVertices(true); Graph<Long, Long, Long> res = graph.runScatterGatherIteration( - new MessageFunction(), new UpdateFunction(), 10, parameters); + new MessageFunction(), new UpdateFunction(), 10, parameters); DataSet<Vertex<Long, Long>> data = res.getVertices(); - List<Vertex<Long, Long>> result= data.collect(); + List<Vertex<Long, Long>> result = data.collect(); expectedResult = "1,11\n" + - "2,11\n" + - "3,11\n" + - "4,11\n" + - "5,11"; + "2,11\n" + + "3,11\n" + + "4,11\n" + + "5,11"; compareResultAsTuples(result, expectedResult); } @Test public void testIterationConfiguration() throws Exception { - /* * Test name, parallelism and solutionSetUnmanaged parameters */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); ScatterGatherIteration<Long, Long, Long, Long> iteration = ScatterGatherIteration - .withEdges(TestGraphUtils.getLongLongEdgeData(env), new DummyMessageFunction(), - new DummyUpdateFunction(), 10); + .withEdges(TestGraphUtils.getLongLongEdgeData(env), new DummyMessageFunction(), + new DummyUpdateFunction(), 10); ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); parameters.setName("gelly iteration"); @@ -109,13 +108,13 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { Assert.assertEquals(true, iteration.getIterationConfiguration().isSolutionSetUnmanagedMemory()); DataSet<Vertex<Long, Long>> data = TestGraphUtils.getLongLongVertexData(env).runOperation(iteration); - List<Vertex<Long, Long>> result= data.collect(); + List<Vertex<Long, Long>> result = data.collect(); expectedResult = "1,11\n" + - "2,12\n" + - "3,13\n" + - "4,14\n" + - "5,15"; + "2,12\n" + + "3,13\n" + + "4,14\n" + + "5,15"; compareResultAsTuples(result, expectedResult); } @@ -129,27 +128,26 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env).mapVertices(new AssignOneMapper()); + TestGraphUtils.getLongLongEdges(), env).mapVertices(new AssignOneMapper()); Graph<Long, Long, Long> res = graph.runScatterGatherIteration( - new MessageFunctionDefault(), new UpdateFunctionDefault(), 5); + new MessageFunctionDefault(), new UpdateFunctionDefault(), 5); DataSet<Tuple2<Long, Long>> data = res.getVertices().map(new VertexToTuple2Map<Long, Long>()); - List<Tuple2<Long, Long>> result= data.collect(); + List<Tuple2<Long, Long>> result = data.collect(); expectedResult = "1,6\n" + - "2,6\n" + - "3,6\n" + - "4,6\n" + - "5,6"; + "2,6\n" + + "3,6\n" + + "4,6\n" + + "5,6"; compareResultAsTuples(result, expectedResult); } @Test public void testIterationDefaultDirection() throws Exception { - /* * Test that if no direction parameter is given, the iteration works as before * (i.e. it collects messages from the in-neighbors and sends them to the out-neighbors) @@ -157,27 +155,26 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) - .mapVertices(new InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) + .mapVertices(new InitialiseHashSetMapper()); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph - .runScatterGatherIteration(new IdMessengerTrg(), new VertexUpdateDirection(), 5) - .getVertices(); + .runScatterGatherIteration(new IdMessengerTrg(), new VertexUpdateDirection(), 5) + .getVertices(); - List<Vertex<Long, HashSet<Long>>> result= resultedVertices.collect(); + List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[5]\n" + - "2,[1]\n" + - "3,[1, 2]\n" + - "4,[3]\n" + - "5,[3, 4]"; + "2,[1]\n" + + "3,[1, 2]\n" + + "4,[3]\n" + + "5,[3, 4]"; compareResultAsTuples(result, expectedResult); } @Test public void testIterationINDirection() throws Exception { - /* * Test that if the direction parameter is set to IN, * messages are collected from the out-neighbors and sent to the in-neighbors. @@ -185,8 +182,8 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) - .mapVertices(new InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) + .mapVertices(new InitialiseHashSetMapper()); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -194,23 +191,22 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setDirection(EdgeDirection.IN); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph - .runScatterGatherIteration(new IdMessengerSrc(), new VertexUpdateDirection(), 5, parameters) - .getVertices(); + .runScatterGatherIteration(new IdMessengerSrc(), new VertexUpdateDirection(), 5, parameters) + .getVertices(); - List<Vertex<Long, HashSet<Long>>> result= resultedVertices.collect(); + List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[2, 3]\n" + - "2,[3]\n" + - "3,[4, 5]\n" + - "4,[5]\n" + - "5,[1]"; + "2,[3]\n" + + "3,[4, 5]\n" + + "4,[5]\n" + + "5,[1]"; compareResultAsTuples(result, expectedResult); } @Test public void testIterationALLDirection() throws Exception { - /* * Test that if the direction parameter is set to ALL, * messages are collected from all the neighbors and sent to all the neighbors. @@ -218,8 +214,8 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) - .mapVertices(new InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) + .mapVertices(new InitialiseHashSetMapper()); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -227,23 +223,22 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setDirection(EdgeDirection.ALL); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph - .runScatterGatherIteration(new IdMessengerAll(), new VertexUpdateDirection(), 5, parameters) - .getVertices(); + .runScatterGatherIteration(new IdMessengerAll(), new VertexUpdateDirection(), 5, parameters) + .getVertices(); - List<Vertex<Long, HashSet<Long>>> result= resultedVertices.collect(); + List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[2, 3, 5]\n" + - "2,[1, 3]\n" + - "3,[1, 2, 4, 5]\n" + - "4,[3, 5]\n" + - "5,[1, 3, 4]"; + "2,[1, 3]\n" + + "3,[1, 2, 4, 5]\n" + + "4,[3, 5]\n" + + "5,[1, 3, 4]"; compareResultAsTuples(result, expectedResult); } @Test public void testSendToAllDirectionIN() throws Exception { - /* * Test that sendMessageToAllNeighbors() works correctly * when the direction is set to IN @@ -251,8 +246,8 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) - .mapVertices(new InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) + .mapVertices(new InitialiseHashSetMapper()); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -260,23 +255,22 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setDirection(EdgeDirection.IN); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph - .runScatterGatherIteration(new SendMsgToAll(), new VertexUpdateDirection(), 5, parameters) - .getVertices(); + .runScatterGatherIteration(new SendMsgToAll(), new VertexUpdateDirection(), 5, parameters) + .getVertices(); List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[2, 3]\n" + - "2,[3]\n" + - "3,[4, 5]\n" + - "4,[5]\n" + - "5,[1]"; + "2,[3]\n" + + "3,[4, 5]\n" + + "4,[5]\n" + + "5,[1]"; compareResultAsTuples(result, expectedResult); } @Test public void testSendToAllDirectionOUT() throws Exception { - /* * Test that sendMessageToAllNeighbors() works correctly * when the direction is set to OUT @@ -284,8 +278,8 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) - .mapVertices(new InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) + .mapVertices(new InitialiseHashSetMapper()); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -293,23 +287,22 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setDirection(EdgeDirection.OUT); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph - .runScatterGatherIteration(new SendMsgToAll(), new VertexUpdateDirection(), 5, parameters) - .getVertices(); + .runScatterGatherIteration(new SendMsgToAll(), new VertexUpdateDirection(), 5, parameters) + .getVertices(); List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[5]\n" + - "2,[1]\n" + - "3,[1, 2]\n" + - "4,[3]\n" + - "5,[3, 4]"; + "2,[1]\n" + + "3,[1, 2]\n" + + "4,[3]\n" + + "5,[3, 4]"; compareResultAsTuples(result, expectedResult); } @Test public void testSendToAllDirectionALL() throws Exception { - /* * Test that sendMessageToAllNeighbors() works correctly * when the direction is set to ALL @@ -317,8 +310,8 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, HashSet<Long>, Long> graph = Graph - .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) - .mapVertices(new InitialiseHashSetMapper()); + .fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env) + .mapVertices(new InitialiseHashSetMapper()); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -326,16 +319,16 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setDirection(EdgeDirection.ALL); DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph - .runScatterGatherIteration(new SendMsgToAll(), new VertexUpdateDirection(), 5, parameters) - .getVertices(); + .runScatterGatherIteration(new SendMsgToAll(), new VertexUpdateDirection(), 5, parameters) + .getVertices(); List<Vertex<Long, HashSet<Long>>> result = resultedVertices.collect(); expectedResult = "1,[2, 3, 5]\n" + - "2,[1, 3]\n" + - "3,[1, 2, 4, 5]\n" + - "4,[3, 5]\n" + - "5,[1, 3, 4]"; + "2,[1, 3]\n" + + "3,[1, 2, 4, 5]\n" + + "4,[3, 5]\n" + + "5,[1, 3, 4]"; compareResultAsTuples(result, expectedResult); } @@ -350,25 +343,24 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env); + TestGraphUtils.getLongLongEdges(), env); DataSet<Vertex<Long, Long>> verticesWithNumVertices = graph.runScatterGatherIteration(new DummyMessageFunction(), - new UpdateFunctionNumVertices(), 2).getVertices(); + new UpdateFunctionNumVertices(), 2).getVertices(); - List<Vertex<Long, Long>> result= verticesWithNumVertices.collect(); + List<Vertex<Long, Long>> result = verticesWithNumVertices.collect(); expectedResult = "1,-1\n" + - "2,-1\n" + - "3,-1\n" + - "4,-1\n" + - "5,-1"; + "2,-1\n" + + "3,-1\n" + + "4,-1\n" + + "5,-1"; compareResultAsTuples(result, expectedResult); } @Test public void testInDegreesSet() throws Exception { - /* * Test that if the degrees are set, they can be accessed in every superstep * inside the update function and the value @@ -377,7 +369,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env); + TestGraphUtils.getLongLongEdges(), env); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -385,47 +377,45 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setOptDegrees(true); DataSet<Vertex<Long, Long>> verticesWithDegrees = graph.runScatterGatherIteration( - new DegreesMessageFunction(), new UpdateFunctionInDegrees(), 5, parameters).getVertices(); + new DegreesMessageFunction(), new UpdateFunctionInDegrees(), 5, parameters).getVertices(); - List<Vertex<Long, Long>> result= verticesWithDegrees.collect(); + List<Vertex<Long, Long>> result = verticesWithDegrees.collect(); expectedResult = "1,1\n" + - "2,1\n" + - "3,2\n" + - "4,1\n" + - "5,2"; + "2,1\n" + + "3,2\n" + + "4,1\n" + + "5,2"; compareResultAsTuples(result, expectedResult); } @Test public void testInDegreesNotSet() throws Exception { - /* * Test that if the degrees option is not set, then -1 is returned as a value for in-degree. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env); + TestGraphUtils.getLongLongEdges(), env); DataSet<Vertex<Long, Long>> verticesWithDegrees = graph.runScatterGatherIteration( - new DummyMessageFunction(), new UpdateFunctionInDegrees(), 2).getVertices(); + new DummyMessageFunction(), new UpdateFunctionInDegrees(), 2).getVertices(); - List<Vertex<Long, Long>> result= verticesWithDegrees.collect(); + List<Vertex<Long, Long>> result = verticesWithDegrees.collect(); expectedResult = "1,-1\n" + - "2,-1\n" + - "3,-1\n" + - "4,-1\n" + - "5,-1"; + "2,-1\n" + + "3,-1\n" + + "4,-1\n" + + "5,-1"; compareResultAsTuples(result, expectedResult); } @Test public void testOutDegreesSet() throws Exception { - /* * Test that if the degrees are set, they can be accessed in every superstep * inside the update function and the value @@ -434,7 +424,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env); + TestGraphUtils.getLongLongEdges(), env); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -442,47 +432,45 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setOptDegrees(true); DataSet<Vertex<Long, Long>> verticesWithDegrees = graph.runScatterGatherIteration( - new DegreesMessageFunction(), new UpdateFunctionOutDegrees(), 5, parameters).getVertices(); + new DegreesMessageFunction(), new UpdateFunctionOutDegrees(), 5, parameters).getVertices(); - List<Vertex<Long, Long>> result= verticesWithDegrees.collect(); + List<Vertex<Long, Long>> result = verticesWithDegrees.collect(); expectedResult = "1,2\n" + - "2,1\n" + - "3,2\n" + - "4,1\n" + - "5,1"; + "2,1\n" + + "3,2\n" + + "4,1\n" + + "5,1"; compareResultAsTuples(result, expectedResult); } @Test public void testOutDegreesNotSet() throws Exception { - /* * Test that if the degrees option is not set, then -1 is returned as a value for out-degree. */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env); + TestGraphUtils.getLongLongEdges(), env); DataSet<Vertex<Long, Long>> verticesWithDegrees = graph.runScatterGatherIteration( - new DummyMessageFunction(), new UpdateFunctionInDegrees(), 2).getVertices(); + new DummyMessageFunction(), new UpdateFunctionOutDegrees(), 2).getVertices(); - List<Vertex<Long, Long>> result= verticesWithDegrees.collect(); + List<Vertex<Long, Long>> result = verticesWithDegrees.collect(); expectedResult = "1,-1\n" + - "2,-1\n" + - "3,-1\n" + - "4,-1\n" + - "5,-1"; + "2,-1\n" + + "3,-1\n" + + "4,-1\n" + + "5,-1"; compareResultAsTuples(result, expectedResult); } @Test public void testDirectionALLAndDegrees() throws Exception { - /* * Compute the number of neighbors in a vertex - centric manner, and verify that it is equal to * the sum: inDegree + outDegree. @@ -490,7 +478,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Boolean, Long> graph = Graph.fromCollection(TestGraphUtils.getLongBooleanVertices(), - TestGraphUtils.getLongLongEdges(), env); + TestGraphUtils.getLongLongEdges(), env); // configure the iteration ScatterGatherConfiguration parameters = new ScatterGatherConfiguration(); @@ -499,15 +487,15 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { parameters.setDirection(EdgeDirection.ALL); DataSet<Vertex<Long, Boolean>> verticesWithNumNeighbors = graph.runScatterGatherIteration( - new IdMessenger(), new VertexUpdateNumNeighbors(), 1, parameters).getVertices(); + new IdMessenger(), new VertexUpdateNumNeighbors(), 1, parameters).getVertices(); - List<Vertex<Long, Boolean>> result= verticesWithNumNeighbors.collect(); + List<Vertex<Long, Boolean>> result = verticesWithNumNeighbors.collect(); expectedResult = "1,true\n" + - "2,true\n" + - "3,true\n" + - "4,true\n" + - "5,true"; + "2,true\n" + + "3,true\n" + + "4,true\n" + + "5,true"; compareResultAsTuples(result, expectedResult); } @@ -530,7 +518,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { // test aggregator if (getSuperstepNumber() == 2) { - long aggrValue = ((LongValue)getPreviousIterationAggregate("superstepAggregator")).getValue(); + long aggrValue = ((LongValue) getPreviousIterationAggregate("superstepAggregator")).getValue(); Assert.assertEquals(5, aggrValue); } } @@ -612,7 +600,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { @Override public void updateVertex(Vertex<Long, Long> vertex, MessageIterator<Long> inMessages) { - setNewVertexValue(getNumberOfVertices()); + setNewVertexValue(getNumberOfVertices()); } } @@ -642,8 +630,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { if (vertex.getId() == 1) { Assert.assertEquals(2, getOutDegree()); Assert.assertEquals(1, getInDegree()); - } - else if(vertex.getId() == 3) { + } else if (vertex.getId() == 3) { Assert.assertEquals(2, getOutDegree()); Assert.assertEquals(2, getInDegree()); } @@ -659,7 +646,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { public void updateVertex(Vertex<Long, HashSet<Long>> vertex, MessageIterator<Long> messages) throws Exception { vertex.getValue().clear(); - for(long msg : messages) { + for (long msg : messages) { vertex.getValue().add(msg); } @@ -688,15 +675,14 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { } @SuppressWarnings("serial") - private static final class VertexUpdateNumNeighbors extends GatherFunction<Long, Boolean, - Long> { + private static final class VertexUpdateNumNeighbors extends GatherFunction<Long, Boolean, Long> { @Override public void updateVertex(Vertex<Long, Boolean> vertex, MessageIterator<Long> messages) throws Exception { long count = 0; - for(@SuppressWarnings("unused") long msg : messages) { + for (@SuppressWarnings("unused") long msg : messages) { count++; } setNewVertexValue(count == (getInDegree() + getOutDegree())); @@ -731,7 +717,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { @Override public void sendMessages(Vertex<Long, HashSet<Long>> vertex) throws Exception { for (Edge<Long, Long> edge : getEdges()) { - if(!edge.getSource().equals(vertex.getId())) { + if (!edge.getSource().equals(vertex.getId())) { sendMessageTo(edge.getSource(), vertex.getId()); } else { sendMessageTo(edge.getTarget(), vertex.getId()); @@ -755,7 +741,7 @@ public class ScatterGatherConfigurationITCase extends MultipleProgramsTestBase { @Override public void sendMessages(Vertex<Long, Boolean> vertex) throws Exception { for (Edge<Long, Long> edge : getEdges()) { - if(!edge.getSource().equals(vertex.getId())) { + if (!edge.getSource().equals(vertex.getId())) { sendMessageTo(edge.getSource(), vertex.getId()); } else { sendMessageTo(edge.getTarget(), vertex.getId()); http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/DegreesITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/DegreesITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/DegreesITCase.java index db2ca0d..280eb92 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/DegreesITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/DegreesITCase.java @@ -18,7 +18,6 @@ package org.apache.flink.graph.test.operations; -import java.util.List; import org.apache.flink.api.java.DataSet; import org.apache.flink.api.java.ExecutionEnvironment; import org.apache.flink.api.java.tuple.Tuple2; @@ -31,149 +30,147 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import java.util.List; + @RunWith(Parameterized.class) public class DegreesITCase extends MultipleProgramsTestBase { - public DegreesITCase(TestExecutionMode mode){ + public DegreesITCase(TestExecutionMode mode) { super(mode); } - private String expectedResult; - + private String expectedResult; @Test public void testOutDegrees() throws Exception { /* * Test outDegrees() */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - - Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), - TestGraphUtils.getLongLongEdgeData(env), env); - - DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees(); - List<Tuple2<Long, LongValue>> result = data.collect(); - - - expectedResult = "1,2\n" + - "2,1\n" + - "3,2\n" + - "4,1\n" + - "5,1\n"; - - compareResultAsTuples(result, expectedResult); - - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), + TestGraphUtils.getLongLongEdgeData(env), env); + + DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees(); + List<Tuple2<Long, LongValue>> result = data.collect(); + + + expectedResult = "1,2\n" + + "2,1\n" + + "3,2\n" + + "4,1\n" + + "5,1\n"; + + compareResultAsTuples(result, expectedResult); + } @Test public void testOutDegreesWithNoOutEdges() throws Exception { /* * Test outDegrees() no outgoing edges */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - - Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), - TestGraphUtils.getLongLongEdgeDataWithZeroDegree(env), env); - - - - DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees(); - List<Tuple2<Long, LongValue>> result = data.collect(); - - expectedResult = "1,3\n" + - "2,1\n" + - "3,1\n" + - "4,1\n" + - "5,0\n"; - - compareResultAsTuples(result, expectedResult); - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), + TestGraphUtils.getLongLongEdgeDataWithZeroDegree(env), env); + + + DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees(); + List<Tuple2<Long, LongValue>> result = data.collect(); + + expectedResult = "1,3\n" + + "2,1\n" + + "3,1\n" + + "4,1\n" + + "5,0\n"; + + compareResultAsTuples(result, expectedResult); + } @Test public void testInDegrees() throws Exception { /* * Test inDegrees() */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), - TestGraphUtils.getLongLongEdgeData(env), env); + Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), + TestGraphUtils.getLongLongEdgeData(env), env); + DataSet<Tuple2<Long, LongValue>> data = graph.inDegrees(); + List<Tuple2<Long, LongValue>> result = data.collect(); - DataSet<Tuple2<Long, LongValue>> data = graph.inDegrees(); - List<Tuple2<Long, LongValue>> result = data.collect(); - - expectedResult = "1,1\n" + - "2,1\n" + - "3,2\n" + - "4,1\n" + - "5,2\n"; - compareResultAsTuples(result, expectedResult); - } + expectedResult = "1,1\n" + + "2,1\n" + + "3,2\n" + + "4,1\n" + + "5,2\n"; + compareResultAsTuples(result, expectedResult); + } @Test public void testInDegreesWithNoInEdge() throws Exception { /* * Test inDegrees() no ingoing edge */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - - Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), - TestGraphUtils.getLongLongEdgeDataWithZeroDegree(env), env); - - DataSet<Tuple2<Long, LongValue>> data = graph.inDegrees(); - List<Tuple2<Long, LongValue>> result = data.collect(); - - expectedResult = "1,0\n" + - "2,1\n" + - "3,1\n" + - "4,1\n" + - "5,3\n"; - - compareResultAsTuples(result, expectedResult); - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), + TestGraphUtils.getLongLongEdgeDataWithZeroDegree(env), env); + + DataSet<Tuple2<Long, LongValue>> data = graph.inDegrees(); + List<Tuple2<Long, LongValue>> result = data.collect(); + + expectedResult = "1,0\n" + + "2,1\n" + + "3,1\n" + + "4,1\n" + + "5,3\n"; + + compareResultAsTuples(result, expectedResult); + } @Test public void testGetDegrees() throws Exception { /* * Test getDegrees() */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - - Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), - TestGraphUtils.getLongLongEdgeData(env), env); - - DataSet<Tuple2<Long, LongValue>> data = graph.getDegrees(); - List<Tuple2<Long, LongValue>> result = data.collect(); - - expectedResult = "1,3\n" + - "2,2\n" + - "3,4\n" + - "4,2\n" + - "5,3\n"; - - compareResultAsTuples(result, expectedResult); - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), + TestGraphUtils.getLongLongEdgeData(env), env); + + DataSet<Tuple2<Long, LongValue>> data = graph.getDegrees(); + List<Tuple2<Long, LongValue>> result = data.collect(); + + expectedResult = "1,3\n" + + "2,2\n" + + "3,4\n" + + "4,2\n" + + "5,3\n"; + + compareResultAsTuples(result, expectedResult); + } @Test public void testGetDegreesWithDisconnectedData() throws Exception { - /* + /* * Test getDegrees() with disconnected data */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - - Graph<Long, NullValue, Long> graph = - Graph.fromDataSet(TestGraphUtils.getDisconnectedLongLongEdgeData(env), env); - - DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees(); - List<Tuple2<Long, LongValue>> result = data.collect(); - - expectedResult = "1,2\n" + - "2,1\n" + - "3,0\n" + - "4,1\n" + - "5,0\n"; - - compareResultAsTuples(result, expectedResult); - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + + Graph<Long, NullValue, Long> graph = + Graph.fromDataSet(TestGraphUtils.getDisconnectedLongLongEdgeData(env), env); + + DataSet<Tuple2<Long, LongValue>> data = graph.outDegrees(); + List<Tuple2<Long, LongValue>> result = data.collect(); + + expectedResult = "1,2\n" + + "2,1\n" + + "3,0\n" + + "4,1\n" + + "5,0\n"; + + compareResultAsTuples(result, expectedResult); + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/FromCollectionITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/FromCollectionITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/FromCollectionITCase.java index 59f416f..ab2ffe0 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/FromCollectionITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/FromCollectionITCase.java @@ -36,84 +36,83 @@ import java.util.List; @RunWith(Parameterized.class) public class FromCollectionITCase extends MultipleProgramsTestBase { - public FromCollectionITCase(TestExecutionMode mode){ + public FromCollectionITCase(TestExecutionMode mode) { super(mode); } - private String expectedResult; - + private String expectedResult; @Test public void testFromCollectionVerticesEdges() throws Exception { /* * Test fromCollection(vertices, edges): */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), - TestGraphUtils.getLongLongEdges(), env); - - DataSet<Edge<Long, Long>> data = graph.getEdges(); - List<Edge<Long, Long>> result= data.collect(); - - expectedResult = "1,2,12\n" + - "1,3,13\n" + - "2,3,23\n" + - "3,4,34\n" + - "3,5,35\n" + - "4,5,45\n" + - "5,1,51\n"; - - compareResultAsTuples(result, expectedResult); - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), + TestGraphUtils.getLongLongEdges(), env); + + DataSet<Edge<Long, Long>> data = graph.getEdges(); + List<Edge<Long, Long>> result = data.collect(); + + expectedResult = "1,2,12\n" + + "1,3,13\n" + + "2,3,23\n" + + "3,4,34\n" + + "3,5,35\n" + + "4,5,45\n" + + "5,1,51\n"; + + compareResultAsTuples(result, expectedResult); + } @Test public void testFromCollectionEdgesNoInitialValue() throws Exception { - /* + /* * Test fromCollection(edges) with no initial value for the vertices */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - Graph<Long, NullValue, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongEdges(), - env); - - - DataSet<Vertex<Long, NullValue>> data = graph.getVertices(); - List<Vertex<Long, NullValue>> result= data.collect(); - - expectedResult = "1,(null)\n" + - "2,(null)\n" + - "3,(null)\n" + - "4,(null)\n" + - "5,(null)\n"; - - compareResultAsTuples(result, expectedResult); - } + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + Graph<Long, NullValue, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongEdges(), + env); + + + DataSet<Vertex<Long, NullValue>> data = graph.getVertices(); + List<Vertex<Long, NullValue>> result = data.collect(); + + expectedResult = "1,(null)\n" + + "2,(null)\n" + + "3,(null)\n" + + "4,(null)\n" + + "5,(null)\n"; + + compareResultAsTuples(result, expectedResult); + } @Test public void testFromCollectionEdgesWithInitialValue() throws Exception { - /* + /* * Test fromCollection(edges) with vertices initialised by a * function that takes the id and doubles it */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongEdges(), - new InitVerticesMapper(), env); - - DataSet<Vertex<Long, Long>> data = graph.getVertices(); - List<Vertex<Long, Long>> result= data.collect(); - - expectedResult = "1,2\n" + - "2,4\n" + - "3,6\n" + - "4,8\n" + - "5,10\n"; - - compareResultAsTuples(result, expectedResult); - } + new InitVerticesMapper(), env); + + DataSet<Vertex<Long, Long>> data = graph.getVertices(); + List<Vertex<Long, Long>> result = data.collect(); + + expectedResult = "1,2\n" + + "2,4\n" + + "3,6\n" + + "4,8\n" + + "5,10\n"; + + compareResultAsTuples(result, expectedResult); + } @SuppressWarnings("serial") private static final class InitVerticesMapper implements MapFunction<Long, Long> { - public Long map(Long vertexId) { - return vertexId * 2; - } + public Long map(Long vertexId) { + return vertexId * 2; + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationITCase.java index 10db9be..77dd4d1 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationITCase.java @@ -40,51 +40,50 @@ import java.util.List; @RunWith(Parameterized.class) public class GraphCreationITCase extends MultipleProgramsTestBase { - public GraphCreationITCase(TestExecutionMode mode){ + public GraphCreationITCase(TestExecutionMode mode) { super(mode); } - - private String expectedResult; + private String expectedResult; @Test public void testCreateWithoutVertexValues() throws Exception { - /* - * Test create() with edge dataset and no vertex values - */ + /* + * Test create() with edge dataset and no vertex values + */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, NullValue, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongEdgeData(env), env); - DataSet<Vertex<Long, NullValue>> data = graph.getVertices(); - List<Vertex<Long, NullValue>> result= data.collect(); - + DataSet<Vertex<Long, NullValue>> data = graph.getVertices(); + List<Vertex<Long, NullValue>> result = data.collect(); + expectedResult = "1,(null)\n" + - "2,(null)\n" + - "3,(null)\n" + - "4,(null)\n" + - "5,(null)\n"; - + "2,(null)\n" + + "3,(null)\n" + + "4,(null)\n" + + "5,(null)\n"; + compareResultAsTuples(result, expectedResult); } @Test public void testCreateWithMapper() throws Exception { - /* - * Test create() with edge dataset and a mapper that assigns the id as value - */ + /* + * Test create() with edge dataset and a mapper that assigns the id as value + */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongEdgeData(env), - new AssignIdAsValueMapper(), env); + new AssignIdAsValueMapper(), env); + + DataSet<Vertex<Long, Long>> data = graph.getVertices(); + List<Vertex<Long, Long>> result = data.collect(); - DataSet<Vertex<Long, Long>> data = graph.getVertices(); - List<Vertex<Long, Long>> result= data.collect(); - expectedResult = "1,1\n" + - "2,2\n" + - "3,3\n" + - "4,4\n" + - "5,5\n"; - + "2,2\n" + + "3,3\n" + + "4,4\n" + + "5,5\n"; + compareResultAsTuples(result, expectedResult); } @@ -95,17 +94,17 @@ public class GraphCreationITCase extends MultipleProgramsTestBase { */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, DummyCustomParameterizedType<Double>, Long> graph = Graph.fromDataSet( - TestGraphUtils.getLongLongEdgeData(env), new AssignCustomVertexValueMapper(), env); + TestGraphUtils.getLongLongEdgeData(env), new AssignCustomVertexValueMapper(), env); + + DataSet<Vertex<Long, DummyCustomParameterizedType<Double>>> data = graph.getVertices(); + List<Vertex<Long, DummyCustomParameterizedType<Double>>> result = data.collect(); - DataSet<Vertex<Long, DummyCustomParameterizedType<Double>>> data = graph.getVertices(); - List<Vertex<Long, DummyCustomParameterizedType<Double>>> result= data.collect(); - expectedResult = "1,(2.0,0)\n" + - "2,(4.0,1)\n" + - "3,(6.0,2)\n" + - "4,(8.0,3)\n" + - "5,(10.0,4)\n"; - + "2,(4.0,1)\n" + + "3,(6.0,2)\n" + + "4,(8.0,3)\n" + + "5,(10.0,4)\n"; + compareResultAsTuples(result, expectedResult); } @@ -122,12 +121,12 @@ public class GraphCreationITCase extends MultipleProgramsTestBase { Boolean valid = graph.validate(new InvalidVertexIdsValidator<Long, Long, Long>()); //env.fromElements(result).writeAsText(resultPath); - - String res= valid.toString();//env.fromElements(valid); - List<String> result= new LinkedList<>(); - result.add(res); + + String res = valid.toString();//env.fromElements(valid); + List<String> result = new LinkedList<>(); + result.add(res); expectedResult = "true"; - + compareResultAsText(result, expectedResult); } @@ -142,13 +141,13 @@ public class GraphCreationITCase extends MultipleProgramsTestBase { Graph<Long, Long, Long> graph = Graph.fromDataSet(vertices, edges, env); Boolean valid = graph.validate(new InvalidVertexIdsValidator<Long, Long, Long>()); - - String res= valid.toString();//env.fromElements(valid); - List<String> result= new LinkedList<>(); - result.add(res); + + String res = valid.toString();//env.fromElements(valid); + List<String> result = new LinkedList<>(); + result.add(res); expectedResult = "false\n"; - + compareResultAsText(result, expectedResult); } @@ -162,18 +161,18 @@ public class GraphCreationITCase extends MultipleProgramsTestBase { Graph<Long, NullValue, NullValue> graph = Graph.fromTuple2DataSet(edges, env); - List<Vertex<Long, NullValue>> result = graph.getVertices().collect(); - + List<Vertex<Long, NullValue>> result = graph.getVertices().collect(); + expectedResult = "1,(null)\n" + - "2,(null)\n" + - "3,(null)\n" + - "4,(null)\n" + - "6,(null)\n" + - "10,(null)\n" + - "20,(null)\n" + - "30,(null)\n" + - "40,(null)\n" + - "60,(null)\n"; + "2,(null)\n" + + "3,(null)\n" + + "4,(null)\n" + + "6,(null)\n" + + "10,(null)\n" + + "20,(null)\n" + + "30,(null)\n" + + "40,(null)\n" + + "60,(null)\n"; compareResultAsTuples(result, expectedResult); } @@ -187,20 +186,20 @@ public class GraphCreationITCase extends MultipleProgramsTestBase { DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env); Graph<Long, String, NullValue> graph = Graph.fromTuple2DataSet(edges, - new BooMapper(), env); + new BooMapper(), env); + + List<Vertex<Long, String>> result = graph.getVertices().collect(); - List<Vertex<Long, String>> result = graph.getVertices().collect(); - expectedResult = "1,boo\n" + - "2,boo\n" + - "3,boo\n" + - "4,boo\n" + - "6,boo\n" + - "10,boo\n" + - "20,boo\n" + - "30,boo\n" + - "40,boo\n" + - "60,boo\n"; + "2,boo\n" + + "3,boo\n" + + "4,boo\n" + + "6,boo\n" + + "10,boo\n" + + "20,boo\n" + + "30,boo\n" + + "40,boo\n" + + "60,boo\n"; compareResultAsTuples(result, expectedResult); } @@ -219,14 +218,16 @@ public class GraphCreationITCase extends MultipleProgramsTestBase { DummyCustomParameterizedType<Double> dummyValue = new DummyCustomParameterizedType<>(); public DummyCustomParameterizedType<Double> map(Long vertexId) { - dummyValue.setIntField(vertexId.intValue()-1); - dummyValue.setTField(vertexId*2.0); + dummyValue.setIntField(vertexId.intValue() - 1); + dummyValue.setTField(vertexId * 2.0); return dummyValue; } } @SuppressWarnings("serial") private static final class BooMapper implements MapFunction<Long, String> { - public String map(Long value) { return "boo"; } + public String map(Long value) { + return "boo"; + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flink/blob/cb282067/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationWithMapperITCase.java ---------------------------------------------------------------------- diff --git a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationWithMapperITCase.java b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationWithMapperITCase.java index f8eb874..148952c 100644 --- a/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationWithMapperITCase.java +++ b/flink-libraries/flink-gelly/src/test/java/org/apache/flink/graph/test/operations/GraphCreationWithMapperITCase.java @@ -36,12 +36,11 @@ import java.util.List; @RunWith(Parameterized.class) public class GraphCreationWithMapperITCase extends MultipleProgramsTestBase { - public GraphCreationWithMapperITCase(TestExecutionMode mode){ + public GraphCreationWithMapperITCase(TestExecutionMode mode) { super(mode); } - private String expectedResult; - + private String expectedResult; @Test public void testWithDoubleValueMapper() throws Exception { @@ -50,17 +49,17 @@ public class GraphCreationWithMapperITCase extends MultipleProgramsTestBase { */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Double, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongEdgeData(env), - new AssignDoubleValueMapper(), env); + new AssignDoubleValueMapper(), env); + + DataSet<Vertex<Long, Double>> data = graph.getVertices(); + List<Vertex<Long, Double>> result = data.collect(); - DataSet<Vertex<Long, Double>> data = graph.getVertices(); - List<Vertex<Long, Double>> result= data.collect(); - expectedResult = "1,0.1\n" + - "2,0.1\n" + - "3,0.1\n" + - "4,0.1\n" + - "5,0.1\n"; - + "2,0.1\n" + + "3,0.1\n" + + "4,0.1\n" + + "5,0.1\n"; + compareResultAsTuples(result, expectedResult); } @@ -71,39 +70,39 @@ public class GraphCreationWithMapperITCase extends MultipleProgramsTestBase { */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, Tuple2<Long, Long>, Long> graph = Graph.fromDataSet( - TestGraphUtils.getLongLongEdgeData(env), new AssignTuple2ValueMapper(), env); + TestGraphUtils.getLongLongEdgeData(env), new AssignTuple2ValueMapper(), env); + + DataSet<Vertex<Long, Tuple2<Long, Long>>> data = graph.getVertices(); + List<Vertex<Long, Tuple2<Long, Long>>> result = data.collect(); - DataSet<Vertex<Long, Tuple2<Long, Long>>> data = graph.getVertices(); - List<Vertex<Long, Tuple2<Long, Long>>> result= data.collect(); - expectedResult = "1,(2,42)\n" + - "2,(4,42)\n" + - "3,(6,42)\n" + - "4,(8,42)\n" + - "5,(10,42)\n"; - + "2,(4,42)\n" + + "3,(6,42)\n" + + "4,(8,42)\n" + + "5,(10,42)\n"; + compareResultAsTuples(result, expectedResult); } @Test public void testWithConstantValueMapper() throws Exception { - /* - * Test create() with edge dataset with String key type - * and a mapper that assigns a double constant as value - */ - final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); - Graph<String, Double, Long> graph = Graph.fromDataSet(TestGraphUtils.getStringLongEdgeData(env), + /* + * Test create() with edge dataset with String key type + * and a mapper that assigns a double constant as value + */ + final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); + Graph<String, Double, Long> graph = Graph.fromDataSet(TestGraphUtils.getStringLongEdgeData(env), new AssignDoubleConstantMapper(), env); - DataSet<Vertex<String, Double>> data = graph.getVertices(); - List<Vertex<String, Double>> result= data.collect(); - - expectedResult = "1,0.1\n" + + DataSet<Vertex<String, Double>> data = graph.getVertices(); + List<Vertex<String, Double>> result = data.collect(); + + expectedResult = "1,0.1\n" + "2,0.1\n" + "3,0.1\n" + "4,0.1\n" + "5,0.1\n"; - + compareResultAsTuples(result, expectedResult); } @@ -114,17 +113,17 @@ public class GraphCreationWithMapperITCase extends MultipleProgramsTestBase { */ final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); Graph<Long, DummyCustomType, Long> graph = Graph.fromDataSet( - TestGraphUtils.getLongLongEdgeData(env), new AssignCustomValueMapper(), env); + TestGraphUtils.getLongLongEdgeData(env), new AssignCustomValueMapper(), env); + + DataSet<Vertex<Long, DummyCustomType>> data = graph.getVertices(); + List<Vertex<Long, DummyCustomType>> result = data.collect(); - DataSet<Vertex<Long, DummyCustomType>> data = graph.getVertices(); - List<Vertex<Long, DummyCustomType>> result= data.collect(); - expectedResult = "1,(F,0)\n" + - "2,(F,1)\n" + - "3,(F,2)\n" + - "4,(F,3)\n" + - "5,(F,4)\n"; - + "2,(F,1)\n" + + "3,(F,2)\n" + + "4,(F,3)\n" + + "5,(F,4)\n"; + compareResultAsTuples(result, expectedResult); } @@ -138,7 +137,7 @@ public class GraphCreationWithMapperITCase extends MultipleProgramsTestBase { @SuppressWarnings("serial") private static final class AssignTuple2ValueMapper implements MapFunction<Long, Tuple2<Long, Long>> { public Tuple2<Long, Long> map(Long vertexId) { - return new Tuple2<>(vertexId*2, 42L); + return new Tuple2<>(vertexId * 2, 42L); } } @@ -152,7 +151,7 @@ public class GraphCreationWithMapperITCase extends MultipleProgramsTestBase { @SuppressWarnings("serial") private static final class AssignCustomValueMapper implements MapFunction<Long, DummyCustomType> { public DummyCustomType map(Long vertexId) { - return new DummyCustomType(vertexId.intValue()-1, false); + return new DummyCustomType(vertexId.intValue() - 1, false); } } }
