org.apache.flink.graph.test.TestGraphUtils.DummyCustomType Java Examples

The following examples show how to use org.apache.flink.graph.test.TestGraphUtils.DummyCustomType. 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: MapVerticesITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithCustomType() throws Exception {
	/*
	 * Test mapVertices() 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<Vertex<Long, DummyCustomType>> mappedVertices = graph.mapVertices(new ToCustomTypeMapper()).getVertices();
	List<Vertex<Long, DummyCustomType>> result = mappedVertices.collect();

	expectedResult = "1,(T,1)\n" +
		"2,(T,2)\n" +
		"3,(T,3)\n" +
		"4,(T,4)\n" +
		"5,(T,5)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #2
Source File: GraphCreationWithMapperITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDCustomValueMapper() throws Exception {
	/*
	 * Test create() with edge dataset and a mapper that assigns a custom vertex value
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, DummyCustomType, Long> graph = Graph.fromDataSet(
		TestGraphUtils.getLongLongEdgeData(env), new AssignCustomValueMapper(), env);

	DataSet<Vertex<Long, DummyCustomType>> data = graph.getVertices();
	List<Vertex<Long, DummyCustomType>> result = data.collect();

	expectedResult = "1,(F,0)\n" +
		"2,(F,1)\n" +
		"3,(F,2)\n" +
		"4,(F,3)\n" +
		"5,(F,4)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #3
Source File: GraphCreationWithMapperITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDCustomValueMapper() throws Exception {
	/*
	 * Test create() with edge dataset and a mapper that assigns a custom vertex value
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, DummyCustomType, Long> graph = Graph.fromDataSet(
		TestGraphUtils.getLongLongEdgeData(env), new AssignCustomValueMapper(), env);

	DataSet<Vertex<Long, DummyCustomType>> data = graph.getVertices();
	List<Vertex<Long, DummyCustomType>> result = data.collect();

	expectedResult = "1,(F,0)\n" +
		"2,(F,1)\n" +
		"3,(F,2)\n" +
		"4,(F,3)\n" +
		"5,(F,4)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #4
Source File: MapEdgesITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #5
Source File: MapVerticesITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithCustomType() throws Exception {
	/*
	 * Test mapVertices() 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<Vertex<Long, DummyCustomType>> mappedVertices = graph.mapVertices(new ToCustomTypeMapper()).getVertices();
	List<Vertex<Long, DummyCustomType>> result = mappedVertices.collect();

	expectedResult = "1,(T,1)\n" +
		"2,(T,2)\n" +
		"3,(T,3)\n" +
		"4,(T,4)\n" +
		"5,(T,5)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #6
Source File: MapVerticesITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithCustomType() throws Exception {
	/*
	 * Test mapVertices() 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<Vertex<Long, DummyCustomType>> mappedVertices = graph.mapVertices(new ToCustomTypeMapper()).getVertices();
	List<Vertex<Long, DummyCustomType>> result = mappedVertices.collect();

	expectedResult = "1,(T,1)\n" +
		"2,(T,2)\n" +
		"3,(T,3)\n" +
		"4,(T,4)\n" +
		"5,(T,5)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #7
Source File: MapEdgesITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #8
Source File: GraphCreationWithMapperITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDCustomValueMapper() throws Exception {
	/*
	 * Test create() with edge dataset and a mapper that assigns a custom vertex value
	 */
	final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
	Graph<Long, DummyCustomType, Long> graph = Graph.fromDataSet(
		TestGraphUtils.getLongLongEdgeData(env), new AssignCustomValueMapper(), env);

	DataSet<Vertex<Long, DummyCustomType>> data = graph.getVertices();
	List<Vertex<Long, DummyCustomType>> result = data.collect();

	expectedResult = "1,(F,0)\n" +
		"2,(F,1)\n" +
		"3,(F,2)\n" +
		"4,(F,3)\n" +
		"5,(F,4)\n";

	compareResultAsTuples(result, expectedResult);
}
 
Example #9
Source File: MapEdgesITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #10
Source File: MapVerticesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Vertex<Long, Long> vertex) throws Exception {
	DummyCustomType dummyValue = new DummyCustomType();
	dummyValue.setIntField(vertex.getValue().intValue());
	return dummyValue;
}
 
Example #11
Source File: GraphCreationWithMapperITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Long vertexId) {
	return new DummyCustomType(vertexId.intValue() - 1, false);
}
 
Example #12
Source File: MapVerticesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Vertex<Long, Long> vertex) throws Exception {
	DummyCustomType dummyValue = new DummyCustomType();
	dummyValue.setIntField(vertex.getValue().intValue());
	return dummyValue;
}
 
Example #13
Source File: MapEdgesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Edge<Long, Long> edge) throws Exception {
	DummyCustomType dummyValue = new DummyCustomType();
	dummyValue.setIntField(edge.getValue().intValue());
	return dummyValue;
}
 
Example #14
Source File: GraphCreationWithMapperITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Long vertexId) {
	return new DummyCustomType(vertexId.intValue() - 1, false);
}
 
Example #15
Source File: MapEdgesITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Edge<Long, Long> edge) throws Exception {
	DummyCustomType dummyValue = new DummyCustomType();
	dummyValue.setIntField(edge.getValue().intValue());
	return dummyValue;
}
 
Example #16
Source File: GraphCreationWithMapperITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Long vertexId) {
	return new DummyCustomType(vertexId.intValue() - 1, false);
}
 
Example #17
Source File: MapVerticesITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Vertex<Long, Long> vertex) throws Exception {
	DummyCustomType dummyValue = new DummyCustomType();
	dummyValue.setIntField(vertex.getValue().intValue());
	return dummyValue;
}
 
Example #18
Source File: MapEdgesITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public DummyCustomType map(Edge<Long, Long> edge) throws Exception {
	DummyCustomType dummyValue = new DummyCustomType();
	dummyValue.setIntField(edge.getValue().intValue());
	return dummyValue;
}