use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborMethodsITCase method testSumOfAllNeighborsNoValue.
@Test
public void testSumOfAllNeighborsNoValue() throws Exception {
/*
* Get the sum of all 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>> verticesWithSumOfAllNeighborValues = graph.reduceOnNeighbors(new SumNeighbors(), EdgeDirection.ALL);
List<Tuple2<Long, Long>> result = verticesWithSumOfAllNeighborValues.collect();
expectedResult = "1,10\n" + "2,4\n" + "3,12\n" + "4,8\n" + "5,8\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnNeighborsWithExceptionITCase method testGroupReduceOnNeighborsInvalidEdgeSrcId.
/**
* Test groupReduceOnNeighbors() -NeighborsFunction-
* with an edge having a srcId that does not exist in the vertex DataSet
*/
@Test
public void testGroupReduceOnNeighborsInvalidEdgeSrcId() 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.getLongLongEdgeInvalidTrgData(env), env);
try {
DataSet<Tuple2<Long, Long>> verticesWithSumOfAllNeighborValues = graph.reduceOnNeighbors(new SumNeighbors(), EdgeDirection.ALL);
verticesWithSumOfAllNeighborValues.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 ReduceOnNeighborsWithExceptionITCase method testGroupReduceOnNeighborsWithVVInvalidEdgeTrgId.
/**
* Test groupReduceOnNeighbors() -NeighborsFunctionWithVertexValue-
* with an edge having a trgId that does not exist in the vertex DataSet
*/
@Test
public void testGroupReduceOnNeighborsWithVVInvalidEdgeTrgId() 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.getLongLongEdgeInvalidTrgData(env), env);
try {
DataSet<Tuple2<Long, Long>> verticesWithSumOfOutNeighborValues = graph.groupReduceOnNeighbors(new SumAllNeighbors(), EdgeDirection.ALL);
verticesWithSumOfOutNeighborValues.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 ReduceOnEdgesMethodsITCase method testAllOutNeighborsWithValueGreaterThanTwo.
@Test
public void testAllOutNeighborsWithValueGreaterThanTwo() throws Exception {
/*
* Get the all the out-neighbors for each vertex that have a value greater than two.
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Tuple2<Long, Long>> verticesWithAllOutNeighbors = graph.groupReduceOnEdges(new SelectOutNeighborsValueGreaterThanTwo(), EdgeDirection.OUT);
List<Tuple2<Long, Long>> result = verticesWithAllOutNeighbors.collect();
expectedResult = "3,4\n" + "3,5\n" + "4,5\n" + "5,1";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.api.java.tuple.Tuple2 in project flink by apache.
the class ReduceOnEdgesMethodsITCase method testLowestWeightInNeighborNoValue.
@Test
public void testLowestWeightInNeighborNoValue() throws Exception {
/*
* Get the lowest-weight out of all the in-neighbors
* of 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>> verticesWithLowestOutNeighbor = graph.reduceOnEdges(new SelectMinWeightNeighborNoValue(), EdgeDirection.IN);
List<Tuple2<Long, Long>> result = verticesWithLowestOutNeighbor.collect();
expectedResult = "1,51\n" + "2,12\n" + "3,13\n" + "4,34\n" + "5,35\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations