org.apache.flink.test.util.TestBaseUtils Java Examples

The following examples show how to use org.apache.flink.test.util.TestBaseUtils. 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: CommunityDetectionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	Graph<IntValue, Long, Double> result = undirectedSimpleGraph
		.mapVertices(v -> (long) v.getId().getValue(),
			new TypeHint<Vertex<IntValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> (double) e.getTarget().getValue() + e.getSource().getValue(),
			new TypeHint<Edge<IntValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

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

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 
Example #2
Source File: MusicProfilesITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@After
public void after() throws Exception {
	TestBaseUtils.compareResultsByLinesInMemory(expectedTopSongs, topSongsResultPath);

	ArrayList<String> list = new ArrayList<>();
	TestBaseUtils.readAllResultLines(list, communitiesResultPath, new String[]{}, false);

	String[] result = list.toArray(new String[list.size()]);
	Arrays.sort(result);

	// check that user_1 and user_2 are in the same community
	Assert.assertEquals("users 1 and 2 are not in the same community",
			result[0].substring(7), result[1].substring(7));

	// check that user_3, user_4 and user_5 are in the same community
	Assert.assertEquals("users 3 and 4 are not in the same community",
			result[2].substring(7), result[3].substring(7));
	Assert.assertEquals("users 4 and 5 are not in the same community",
			result[3].substring(7), result[4].substring(7));
}
 
Example #3
Source File: HiveTableSourceITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSourceConfig() throws Exception {
	// vector reader not available for 1.x and we're not testing orc for 2.0.x
	Assume.assumeTrue(HiveVersionTestUtil.HIVE_210_OR_LATER);
	Map<String, String> env = System.getenv();
	hiveShell.execute("create database db1");
	try {
		hiveShell.execute("create table db1.src (x int,y string) stored as orc");
		hiveShell.execute("insert into db1.src values (1,'a'),(2,'b')");
		testSourceConfig(true, true);
		testSourceConfig(false, false);
	} finally {
		TestBaseUtils.setEnv(env);
		hiveShell.execute("drop database db1 cascade");
	}
}
 
Example #4
Source File: JaccardIndexTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleGraph() throws Exception {
	DataSet<Result<IntValue>> ji = undirectedSimpleGraph
		.run(new JaccardIndex<>());

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

	TestBaseUtils.compareResultAsText(ji.collect(), expectedResult);
}
 
Example #5
Source File: EdgeSourceDegreesTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(2,2,0)))\n" +
		"(0,2,((null),(2,2,0)))\n" +
		"(2,1,((null),(3,2,1)))\n" +
		"(2,3,((null),(3,2,1)))\n" +
		"(3,1,((null),(4,2,2)))\n" +
		"(3,4,((null),(4,2,2)))\n" +
		"(5,3,((null),(1,1,0)))";

	DataSet<Edge<IntValue, Tuple2<NullValue, Degrees>>> sourceDegrees = directedSimpleGraph
			.run(new EdgeSourceDegrees<>());

	TestBaseUtils.compareResultAsText(sourceDegrees.collect(), expectedResult);
}
 
Example #6
Source File: VertexOutDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> outDegreeWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexOutDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, outDegreeWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, LongValue>> outDegreeWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexOutDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(outDegreeWithZeroDegreeVertices.collect(), expectedResult);
}
 
Example #7
Source File: VertexInDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> inDegree = directedSimpleGraph
		.run(new VertexInDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

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

	TestBaseUtils.compareResultAsText(inDegree.collect(), expectedResult);
}
 
Example #8
Source File: CommunityDetectionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSingletonEdgeGraph() throws Exception {
	Graph<LongValue, Long, Double> result = new SingletonEdgeGraph(env, 1)
		.generate()
		.mapVertices(v -> v.getId().getValue(),
			new TypeHint<Vertex<LongValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> 1.0,
			new TypeHint<Edge<LongValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

	String expectedResult =
		"(0,0)\n" +
		"(1,1)\n";

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 
Example #9
Source File: MaximumDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	Graph<IntValue, NullValue, NullValue> graph = undirectedSimpleGraph
		.run(new MaximumDegree<>(3));

	String expectedVerticesResult =
		"(0,(null))\n" +
		"(1,(null))\n" +
		"(2,(null))\n" +
		"(4,(null))\n" +
		"(5,(null))";

	TestBaseUtils.compareResultAsText(graph.getVertices().collect(), expectedVerticesResult);

	String expectedEdgesResult =
		"(0,1,(null))\n" +
		"(0,2,(null))\n" +
		"(1,0,(null))\n" +
		"(1,2,(null))\n" +
		"(2,0,(null))\n" +
		"(2,1,(null))";

	TestBaseUtils.compareResultAsText(graph.getEdges().collect(), expectedEdgesResult);
}
 
Example #10
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskmanagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(NUM_TASK_MANAGERS, taskManagers.size());

	JsonNode taskManager = taskManagers.get(0);
	assertNotNull(taskManager);
	assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
	assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
}
 
Example #11
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getNumberOfTaskManagers() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode response = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

		assertNotNull(taskManagers);
		assertEquals(NUM_TASK_MANAGERS, taskManagers.size());
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #12
Source File: VertexInDegreeTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithUndirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> inDegree = undirectedSimpleGraph
		.run(new VertexInDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

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

	TestBaseUtils.compareResultAsText(inDegree.collect(), expectedResult);
}
 
Example #13
Source File: VertexDegreesTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, Degrees>> degreesWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexDegrees<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degreesWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, Degrees>> degreesWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexDegrees<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,(0,0,0))\n" +
		"(1,(0,0,0))\n" +
		"(2,(0,0,0))";

	TestBaseUtils.compareResultAsText(degreesWithZeroDegreeVertices.collect(), expectedResult);
}
 
Example #14
Source File: EdgeTargetDegreesTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(3,0,3)))\n" +
		"(0,2,((null),(3,2,1)))\n" +
		"(2,1,((null),(3,0,3)))\n" +
		"(2,3,((null),(4,2,2)))\n" +
		"(3,1,((null),(3,0,3)))\n" +
		"(3,4,((null),(1,0,1)))\n" +
		"(5,3,((null),(4,2,2)))";

	DataSet<Edge<IntValue, Tuple2<NullValue, Degrees>>> targetDegrees = directedSimpleGraph
			.run(new EdgeTargetDegrees<>());

	TestBaseUtils.compareResultAsText(targetDegrees.collect(), expectedResult);
}
 
Example #15
Source File: VertexOutDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithDirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> outDegree = directedSimpleGraph
		.run(new VertexOutDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

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

	TestBaseUtils.compareResultAsText(outDegree.collect(), expectedResult);
}
 
Example #16
Source File: EdgeDegreesPairTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),(2,2,0),(3,0,3)))\n" +
		"(0,2,((null),(2,2,0),(3,2,1)))\n" +
		"(2,1,((null),(3,2,1),(3,0,3)))\n" +
		"(2,3,((null),(3,2,1),(4,2,2)))\n" +
		"(3,1,((null),(4,2,2),(3,0,3)))\n" +
		"(3,4,((null),(4,2,2),(1,0,1)))\n" +
		"(5,3,((null),(1,1,0),(4,2,2)))";

	DataSet<Edge<IntValue, Tuple3<NullValue, Degrees, Degrees>>> degreesPair = directedSimpleGraph
		.run(new EdgeDegreesPair<>());

	TestBaseUtils.compareResultAsText(degreesPair.collect(), expectedResult);
}
 
Example #17
Source File: AdamicAdarTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	DataSet<Result<IntValue>> aa = undirectedSimpleGraph
		.run(new AdamicAdar<>());

	String expectedResult =
		"(0,1," + ilog[2] + ")\n" +
		"(0,2," + ilog[1] + ")\n" +
		"(0,3," + (ilog[1] + ilog[2]) + ")\n" +
		"(1,2," + (ilog[0] + ilog[3]) + ")\n" +
		"(1,3," + ilog[2] + ")\n" +
		"(1,4," + ilog[3] + ")\n" +
		"(1,5," + ilog[3] + ")\n" +
		"(2,3," + ilog[1] + ")\n" +
		"(2,4," + ilog[3] + ")\n" +
		"(2,5," + ilog[3] + ")\n" +
		"(4,5," + ilog[3] + ")";

	TestBaseUtils.compareResultAsText(aa.collect(), expectedResult);
}
 
Example #18
Source File: VertexDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> degree;

	degree = emptyGraphWithVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degree.collect().size());

	degree = emptyGraphWithVertices
		.run(new VertexDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(degree.collect(), expectedResult);
}
 
Example #19
Source File: JaccardIndexTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSimpleGraph() throws Exception {
	DataSet<Result<IntValue>> ji = undirectedSimpleGraph
		.run(new JaccardIndex<>());

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

	TestBaseUtils.compareResultAsText(ji.collect(), expectedResult);
}
 
Example #20
Source File: JaccardIndexTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraphWithMaximumScore() throws Exception {
	DataSet<Result<IntValue>> ji = undirectedSimpleGraph
		.run(new JaccardIndex<IntValue, NullValue, NullValue>()
			.setMaximumScore(1, 2));

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

	TestBaseUtils.compareResultAsText(ji.collect(), expectedResult);
}
 
Example #21
Source File: VertexOutDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithUndirectedSimpleGraph() throws Exception {
	DataSet<Vertex<IntValue, LongValue>> outDegree = undirectedSimpleGraph
		.run(new VertexOutDegree<IntValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

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

	TestBaseUtils.compareResultAsText(outDegree.collect(), expectedResult);
}
 
Example #22
Source File: WebFrontendITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskManagerLogAndStdoutFiles() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode parsed = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
		JsonNode taskManager = taskManagers.get(0);
		String id = taskManager.get("id").asText();

		WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

		//we check for job manager log files, since no separate taskmanager logs exist
		FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
		String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/log");
		assertTrue(logs.contains("job manager log"));

		FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
		logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/stdout");
		assertTrue(logs.contains("job manager out"));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #23
Source File: CommunityDetectionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	Graph<IntValue, Long, Double> result = undirectedSimpleGraph
		.mapVertices(v -> (long) v.getId().getValue(),
			new TypeHint<Vertex<IntValue, Long>>(){}.getTypeInfo())
		.mapEdges(e -> (double) e.getTarget().getValue() + e.getSource().getValue(),
			new TypeHint<Edge<IntValue, Double>>(){}.getTypeInfo())
		.run(new CommunityDetection<>(10, 0.5));

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

	TestBaseUtils.compareResultAsText(result.getVertices().collect(), expectedResult);
}
 
Example #24
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void getNumberOfTaskManagers() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode response = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) response.get("taskmanagers");

		assertNotNull(taskManagers);
		assertEquals(NUM_TASK_MANAGERS, taskManagers.size());
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #25
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskmanagers() throws Exception {
	String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

	ObjectMapper mapper = new ObjectMapper();
	JsonNode parsed = mapper.readTree(json);
	ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");

	assertNotNull(taskManagers);
	assertEquals(NUM_TASK_MANAGERS, taskManagers.size());

	JsonNode taskManager = taskManagers.get(0);
	assertNotNull(taskManager);
	assertEquals(NUM_SLOTS, taskManager.get("slotsNumber").asInt());
	assertTrue(taskManager.get("freeSlots").asInt() <= NUM_SLOTS);
}
 
Example #26
Source File: WebFrontendITCase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void getTaskManagerLogAndStdoutFiles() {
	try {
		String json = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/");

		ObjectMapper mapper = new ObjectMapper();
		JsonNode parsed = mapper.readTree(json);
		ArrayNode taskManagers = (ArrayNode) parsed.get("taskmanagers");
		JsonNode taskManager = taskManagers.get(0);
		String id = taskManager.get("id").asText();

		WebMonitorUtils.LogFileLocation logFiles = WebMonitorUtils.LogFileLocation.find(CLUSTER_CONFIGURATION);

		//we check for job manager log files, since no separate taskmanager logs exist
		FileUtils.writeStringToFile(logFiles.logFile, "job manager log");
		String logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/log");
		assertTrue(logs.contains("job manager log"));

		FileUtils.writeStringToFile(logFiles.stdOutFile, "job manager out");
		logs = TestBaseUtils.getFromHTTP("http://localhost:" + getRestPort() + "/taskmanagers/" + id + "/stdout");
		assertTrue(logs.contains("job manager out"));
	} catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #27
Source File: VertexDegreesTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, Degrees>> degreesWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexDegrees<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, degreesWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, Degrees>> degreesWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexDegrees<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,(0,0,0))\n" +
		"(1,(0,0,0))\n" +
		"(2,(0,0,0))";

	TestBaseUtils.compareResultAsText(degreesWithZeroDegreeVertices.collect(), expectedResult);
}
 
Example #28
Source File: AdamicAdarTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithSimpleGraphWithMinimumScore() throws Exception {
	DataSet<Result<IntValue>> aa = undirectedSimpleGraph
		.run(new AdamicAdar<IntValue, NullValue, NullValue>()
			.setMinimumScore(0.75f));

	String expectedResult =
		"(0,1," + ilog[2] + ")\n" +
		"(0,2," + ilog[1] + ")\n" +
		"(0,3," + (ilog[1] + ilog[2]) + ")\n" +
		"(1,2," + (ilog[0] + ilog[3]) + ")\n" +
		"(1,3," + ilog[2] + ")\n" +
		"(2,3," + ilog[1] + ")";

	TestBaseUtils.compareResultAsText(aa.collect(), expectedResult);
}
 
Example #29
Source File: VertexInDegreeTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithEmptyGraphWithVertices() throws Exception {
	DataSet<Vertex<LongValue, LongValue>> inDegreeWithoutZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexInDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(false));

	assertEquals(0, inDegreeWithoutZeroDegreeVertices.collect().size());

	DataSet<Vertex<LongValue, LongValue>> inDegreeWithZeroDegreeVertices = emptyGraphWithVertices
		.run(new VertexInDegree<LongValue, NullValue, NullValue>()
			.setIncludeZeroDegreeVertices(true));

	String expectedResult =
		"(0,0)\n" +
		"(1,0)\n" +
		"(2,0)";

	TestBaseUtils.compareResultAsText(inDegreeWithZeroDegreeVertices.collect(), expectedResult);
}
 
Example #30
Source File: EdgeTargetDegreeTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithSimpleGraph() throws Exception {
	String expectedResult =
		"(0,1,((null),3))\n" +
		"(0,2,((null),3))\n" +
		"(1,0,((null),2))\n" +
		"(1,2,((null),3))\n" +
		"(1,3,((null),4))\n" +
		"(2,0,((null),2))\n" +
		"(2,1,((null),3))\n" +
		"(2,3,((null),4))\n" +
		"(3,1,((null),3))\n" +
		"(3,2,((null),3))\n" +
		"(3,4,((null),1))\n" +
		"(3,5,((null),1))\n" +
		"(4,3,((null),4))\n" +
		"(5,3,((null),4))";

	DataSet<Edge<IntValue, Tuple2<NullValue, LongValue>>> targetDegreeOnTargetId = undirectedSimpleGraph
		.run(new EdgeTargetDegree<IntValue, NullValue, NullValue>()
			.setReduceOnSourceId(false));

	TestBaseUtils.compareResultAsText(targetDegreeOnTargetId.collect(), expectedResult);

	DataSet<Edge<IntValue, Tuple2<NullValue, LongValue>>> targetDegreeOnSourceId = undirectedSimpleGraph
		.run(new EdgeTargetDegree<IntValue, NullValue, NullValue>()
			.setReduceOnSourceId(true));

	TestBaseUtils.compareResultAsText(targetDegreeOnSourceId.collect(), expectedResult);
}