use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesMethodsITCase method testAllInNeighborsNoValue.
@Test
public void testAllInNeighborsNoValue() throws Exception {
/*
* Get the all the in-neighbors for each vertex except for the vertex with id 5.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithAllInNeighbors = graph.groupReduceOnEdges(new SelectInNeighborsExceptFive(), EdgeDirection.IN);
List<Tuple2<Long, Long>> result = verticesWithAllInNeighbors.collect();
expectedResult = "1,5\n" + "2,1\n" + "3,1\n" + "3,2\n" + "4,3";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesWithExceptionITCase method testGroupReduceOnEdgesInvalidEdgeSrcId.
/**
* Test groupReduceOnEdges() with an edge having a srcId that does not exist in the vertex DataSet
*/
@Test
public void testGroupReduceOnEdgesInvalidEdgeSrcId() throws Exception {
final ExecutionEnvironment env = ExecutionEnvironment.createRemoteEnvironment("localhost", cluster.getLeaderRPCPort());
env.setParallelism(PARALLELISM);
env.getConfig().disableSysoutLogging();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeInvalidSrcData(env), env);
try {
DataSet<Tuple2<Long, Long>> verticesWithAllNeighbors = graph.groupReduceOnEdges(new SelectNeighborsValueGreaterThanFour(), EdgeDirection.ALL);
verticesWithAllNeighbors.output(new DiscardingOutputFormat<Tuple2<Long, Long>>());
env.execute();
} catch (Exception e) {
// We expect the job to fail with an exception
}
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfOutNeighbors.
@Test
public void testSumOfOutNeighbors() throws Exception {
/*
* Get the sum of out-neighbor values
* for each vertex
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumOutNeighbors(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect();
expectedResult = "1,5\n" + "2,3\n" + "3,9\n" + "4,5\n" + "5,1\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo.
@Test
public void testSumOfOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo() throws Exception {
/*
* Get the sum of out-neighbor values
* for each vertex with id greater than two as well as the same sum multiplied by two.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumOutNeighborsNoValueMultipliedByTwoIdGreaterThanTwo(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithSumOfOutNeighborValues.collect();
expectedResult = "3,9\n" + "3,18\n" + "4,5\n" + "4,10\n" + "5,1\n" + "5,2";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfInNeighborsIdGreaterThanThree.
@Test
public void testSumOfInNeighborsIdGreaterThanThree() throws Exception {
/*
* Get the sum of in-neighbor values
* times the edge weights for each vertex with id greater than three.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithSum = graph.groupReduceOnNeighbors(new SumInNeighborsIdGreaterThanThree(), EdgeDirection.IN);
List<Tuple2<Long, Long>> result = verticesWithSum.collect();
expectedResult = "4,102\n" + "5,285\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations