use of org.apache.flink.graph.utils.EdgeToTuple3Map in project flink by apache.
the class JoinWithEdgesITCase method testWithLessElements.
@Test
public void testWithLessElements() throws Exception {
/*
* Test joinWithEdges with the input DataSet passed as a parameter containing
* less elements than the edge DataSet, but of the same type
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
Graph<Long, Long, Long> res = graph.joinWithEdges(graph.getEdges().first(3).map(new EdgeToTuple3Map<Long, Long>()), new AddValuesMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,34\n" + "3,5,35\n" + "4,5,45\n" + "5,1,51\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.utils.EdgeToTuple3Map in project flink by apache.
the class JoinWithEdgesITCase method testWithEdgesInputDataset.
@Test
public void testWithEdgesInputDataset() throws Exception {
/*
* Test joinWithEdges with the input DataSet parameter identical
* to the edge DataSet
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
Graph<Long, Long, Long> res = graph.joinWithEdges(graph.getEdges().map(new EdgeToTuple3Map<Long, Long>()), new AddValuesMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,24\n" + "1,3,26\n" + "2,3,46\n" + "3,4,68\n" + "3,5,70\n" + "4,5,90\n" + "5,1,102\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations