use of org.apache.flink.graph.Edge in project flink by apache.
the class JoinWithEdgesITCase method testOnSourceWithLessElements.
@Test
public void testOnSourceWithLessElements() throws Exception {
/*
* Test joinWithEdgesOnSource 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.joinWithEdgesOnSource(graph.getEdges().first(3).map(new ProjectSourceAndValueMapper()), new AddValuesMapper());
DataSet<Edge<Long, Long>> data = res.getEdges();
List<Edge<Long, Long>> result = data.collect();
expectedResult = "1,2,24\n" + "1,3,25\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.Edge in project flink by apache.
the class JoinWithEdgesITCase method testWithOnTargetWithLessElements.
@Test
public void testWithOnTargetWithLessElements() throws Exception {
/*
* Test joinWithEdgesOnTarget 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.joinWithEdgesOnTarget(graph.getEdges().first(3).map(new ProjectTargetAndValueMapper()), 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,36\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.Edge in project flink by apache.
the class MapEdgesITCase method testWithParametrizedCustomType.
@Test
public void testWithParametrizedCustomType() throws Exception {
/*
* Test mapEdges() and change the value type to a parameterized custom type
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Edge<Long, DummyCustomParameterizedType<Double>>> mappedEdges = graph.mapEdges(new ToCustomParametrizedTypeMapper()).getEdges();
List<Edge<Long, DummyCustomParameterizedType<Double>>> result = mappedEdges.collect();
expectedResult = "1,2,(12.0,12)\n" + "1,3,(13.0,13)\n" + "2,3,(23.0,23)\n" + "3,4,(34.0,34)\n" + "3,5,(35.0,35)\n" + "4,5,(45.0,45)\n" + "5,1,(51.0,51)\n";
compareResultAsTuples(result, expectedResult);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class MapEdgesITCase method testWithTuple1Type.
@Test
public void testWithTuple1Type() throws Exception {
/*
* Test mapEdges() and change the value type to a Tuple1
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Edge<Long, Tuple1<Long>>> mappedEdges = graph.mapEdges(new ToTuple1Mapper()).getEdges();
List<Edge<Long, Tuple1<Long>>> result = mappedEdges.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);
}
use of org.apache.flink.graph.Edge in project flink by apache.
the class MapEdgesITCase method testWithCustomType.
@Test
public void testWithCustomType() throws Exception {
/*
* Test mapEdges() and change the value type to a custom type
*/
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
Graph<Long, Long, Long> graph = Graph.fromDataSet(TestGraphUtils.getLongLongVertexData(env), TestGraphUtils.getLongLongEdgeData(env), env);
DataSet<Edge<Long, DummyCustomType>> mappedEdges = graph.mapEdges(new ToCustomTypeMapper()).getEdges();
List<Edge<Long, DummyCustomType>> result = mappedEdges.collect();
expectedResult = "1,2,(T,12)\n" + "1,3,(T,13)\n" + "2,3,(T,23)\n" + "3,4,(T,34)\n" + "3,5,(T,35)\n" + "4,5,(T,45)\n" + "5,1,(T,51)\n";
compareResultAsTuples(result, expectedResult);
}
Aggregations