Search in sources :

Example 11 with ScatterGatherConfiguration

use of org.apache.flink.graph.spargel.ScatterGatherConfiguration in project flink by apache.

the class ScatterGatherConfigurationITCase method testIterationConfiguration.

@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);
    ScatterGatherConfiguration parameters = new ScatterGatherConfiguration();
    parameters.setName("gelly iteration");
    parameters.setParallelism(2);
    parameters.setSolutionSetUnmanagedMemory(true);
    iteration.configure(parameters);
    Assert.assertEquals("gelly iteration", iteration.getIterationConfiguration().getName(""));
    Assert.assertEquals(2, iteration.getIterationConfiguration().getParallelism());
    Assert.assertEquals(true, iteration.getIterationConfiguration().isSolutionSetUnmanagedMemory());
    DataSet<Vertex<Long, Long>> data = TestGraphUtils.getLongLongVertexData(env).runOperation(iteration);
    List<Vertex<Long, Long>> result = data.collect();
    expectedResult = "1,11\n" + "2,12\n" + "3,13\n" + "4,14\n" + "5,15";
    compareResultAsTuples(result, expectedResult);
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ScatterGatherConfiguration(org.apache.flink.graph.spargel.ScatterGatherConfiguration) Test(org.junit.Test)

Example 12 with ScatterGatherConfiguration

use of org.apache.flink.graph.spargel.ScatterGatherConfiguration in project flink by apache.

the class ScatterGatherConfigurationITCase method testSendToAllDirectionOUT.

@Test
public void testSendToAllDirectionOUT() throws Exception {
    /*
		 * Test that sendMessageToAllNeighbors() works correctly
		 * when the direction is set to OUT
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, HashSet<Long>, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env).mapVertices(new InitialiseHashSetMapper());
    // configure the iteration
    ScatterGatherConfiguration parameters = new ScatterGatherConfiguration();
    parameters.setDirection(EdgeDirection.OUT);
    DataSet<Vertex<Long, HashSet<Long>>> resultedVertices = graph.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]";
    compareResultAsTuples(result, expectedResult);
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ScatterGatherConfiguration(org.apache.flink.graph.spargel.ScatterGatherConfiguration) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 13 with ScatterGatherConfiguration

use of org.apache.flink.graph.spargel.ScatterGatherConfiguration in project flink by apache.

the class ScatterGatherConfigurationITCase method testInDegreesSet.

@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
		 * is correctly computed for degrees in the scatter function.
		 */
    final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
    Graph<Long, Long, Long> graph = Graph.fromCollection(TestGraphUtils.getLongLongVertices(), TestGraphUtils.getLongLongEdges(), env);
    // configure the iteration
    ScatterGatherConfiguration parameters = new ScatterGatherConfiguration();
    parameters.setOptDegrees(true);
    DataSet<Vertex<Long, Long>> verticesWithDegrees = graph.runScatterGatherIteration(new DegreesMessageFunction(), new UpdateFunctionInDegrees(), 5, parameters).getVertices();
    List<Vertex<Long, Long>> result = verticesWithDegrees.collect();
    expectedResult = "1,1\n" + "2,1\n" + "3,2\n" + "4,1\n" + "5,2";
    compareResultAsTuples(result, expectedResult);
}
Also used : Vertex(org.apache.flink.graph.Vertex) ExecutionEnvironment(org.apache.flink.api.java.ExecutionEnvironment) ScatterGatherConfiguration(org.apache.flink.graph.spargel.ScatterGatherConfiguration) Test(org.junit.Test)

Aggregations

ScatterGatherConfiguration (org.apache.flink.graph.spargel.ScatterGatherConfiguration)13 ExecutionEnvironment (org.apache.flink.api.java.ExecutionEnvironment)12 Vertex (org.apache.flink.graph.Vertex)12 Test (org.junit.Test)11 HashSet (java.util.HashSet)5 LongSumAggregator (org.apache.flink.api.common.aggregators.LongSumAggregator)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 Edge (org.apache.flink.graph.Edge)1 IncrementalSSSP (org.apache.flink.graph.examples.IncrementalSSSP)1