Java Code Examples for org.apache.flink.graph.Graph#fromTuple2DataSet()

The following examples show how to use org.apache.flink.graph.Graph#fromTuple2DataSet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphCreationITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTuple2() throws Exception {
	/*
	 * Test graph creation with fromTuple2DataSet
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);

	Graph<Long, NullValue, NullValue> graph = Graph.fromTuple2DataSet(edges, env);

	List<Vertex<Long, NullValue>> result = graph.getVertices().collect();

	expectedResult = "1,(null)\n" +
		"2,(null)\n" +
		"3,(null)\n" +
		"4,(null)\n" +
		"6,(null)\n" +
		"10,(null)\n" +
		"20,(null)\n" +
		"30,(null)\n" +
		"40,(null)\n" +
		"60,(null)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 2
Source File: GraphCreationITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTuple2WithMapper() throws Exception {
	/*
	 * Test graph creation with fromTuple2DataSet with vertex initializer
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);

	Graph<Long, String, NullValue> graph = Graph.fromTuple2DataSet(edges,
		new BooMapper(), env);

	List<Vertex<Long, String>> result = graph.getVertices().collect();

	expectedResult = "1,boo\n" +
		"2,boo\n" +
		"3,boo\n" +
		"4,boo\n" +
		"6,boo\n" +
		"10,boo\n" +
		"20,boo\n" +
		"30,boo\n" +
		"40,boo\n" +
		"60,boo\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 3
Source File: GraphCreationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTuple2() throws Exception {
	/*
	 * Test graph creation with fromTuple2DataSet
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);

	Graph<Long, NullValue, NullValue> graph = Graph.fromTuple2DataSet(edges, env);

	List<Vertex<Long, NullValue>> result = graph.getVertices().collect();

	expectedResult = "1,(null)\n" +
		"2,(null)\n" +
		"3,(null)\n" +
		"4,(null)\n" +
		"6,(null)\n" +
		"10,(null)\n" +
		"20,(null)\n" +
		"30,(null)\n" +
		"40,(null)\n" +
		"60,(null)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 4
Source File: GraphCreationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTuple2WithMapper() throws Exception {
	/*
	 * Test graph creation with fromTuple2DataSet with vertex initializer
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);

	Graph<Long, String, NullValue> graph = Graph.fromTuple2DataSet(edges,
		new BooMapper(), env);

	List<Vertex<Long, String>> result = graph.getVertices().collect();

	expectedResult = "1,boo\n" +
		"2,boo\n" +
		"3,boo\n" +
		"4,boo\n" +
		"6,boo\n" +
		"10,boo\n" +
		"20,boo\n" +
		"30,boo\n" +
		"40,boo\n" +
		"60,boo\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 5
Source File: GraphCreationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTuple2() throws Exception {
	/*
	 * Test graph creation with fromTuple2DataSet
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);

	Graph<Long, NullValue, NullValue> graph = Graph.fromTuple2DataSet(edges, env);

	List<Vertex<Long, NullValue>> result = graph.getVertices().collect();

	expectedResult = "1,(null)\n" +
		"2,(null)\n" +
		"3,(null)\n" +
		"4,(null)\n" +
		"6,(null)\n" +
		"10,(null)\n" +
		"20,(null)\n" +
		"30,(null)\n" +
		"40,(null)\n" +
		"60,(null)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example 6
Source File: GraphCreationITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testFromTuple2WithMapper() throws Exception {
	/*
	 * Test graph creation with fromTuple2DataSet with vertex initializer
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	DataSet<Tuple2<Long, Long>> edges = TestGraphUtils.getLongLongTuple2Data(env);

	Graph<Long, String, NullValue> graph = Graph.fromTuple2DataSet(edges,
		new BooMapper(), env);

	List<Vertex<Long, String>> result = graph.getVertices().collect();

	expectedResult = "1,boo\n" +
		"2,boo\n" +
		"3,boo\n" +
		"4,boo\n" +
		"6,boo\n" +
		"10,boo\n" +
		"20,boo\n" +
		"30,boo\n" +
		"40,boo\n" +
		"60,boo\n";

	compareResultAsTuples(result, expectedResult);
}