MCPcopy Create free account
hub / github.com/apache/pig / testMultipleMRJobs

Method testMultipleMRJobs

test/org/apache/pig/test/TestCounters.java:400–462  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

398 }
399
400 @Test
401 public void testMultipleMRJobs() throws IOException, ExecException {
402 Assume.assumeTrue("Skip this test for TEZ. Assert is done only for first MR job",
403 Util.isMapredExecType(cluster.getExecType()));
404 int count = 0;
405 PrintWriter pw = new PrintWriter(Util.createInputFile(cluster, file));
406 int [] nos = new int[10];
407 for(int i = 0; i < 10; i++)
408 nos[i] = 0;
409
410 for(int i = 0; i < MAX; i++) {
411 int index = r.nextInt(10);
412 int value = r.nextInt(100);
413 nos[index] += value;
414 pw.println(index + "\t" + value);
415 }
416 pw.close();
417
418 for(int i = 0; i < 10; i++) {
419 if(nos[i] > 0) count ++;
420 }
421
422 PigServer pigServer = new PigServer(cluster.getExecType(), cluster.getProperties());
423 pigServer.registerQuery("a = load '" + file + "';");
424 pigServer.registerQuery("b = order a by $0;");
425 pigServer.registerQuery("c = group b by $0;");
426 pigServer.registerQuery("d = foreach c generate group, SUM(b.$1);");
427 ExecJob job = pigServer.store("d", "output");
428 PigStats pigStats = job.getStatistics();
429
430 InputStream is = FileLocalizer.open(FileLocalizer.fullPath("output",
431 pigServer.getPigContext()), pigServer.getPigContext());
432 long filesize = 0;
433 while(is.read() != -1) filesize++;
434
435 is.close();
436
437 cluster.getFileSystem().delete(new Path(file), true);
438 cluster.getFileSystem().delete(new Path("output"), true);
439
440 System.out.println("============================================");
441 System.out.println("Test case MultipleMRJobs");
442 System.out.println("============================================");
443
444 JobGraph jp = pigStats.getJobGraph();
445 JobStats js = (JobStats)jp.getSinks().get(0);
446
447 System.out.println("Job id: " + js.getName());
448 System.out.println(jp.toString());
449
450 System.out.println("Map input records : " + js.getMapInputRecords());
451 assertEquals(MAX, js.getMapInputRecords());
452 System.out.println("Map output records : " + js.getMapOutputRecords());
453 assertEquals(MAX, js.getMapOutputRecords());
454 System.out.println("Reduce input records : " + js.getReduceInputRecords());
455 assertEquals(count, js.getReduceInputRecords());
456 System.out.println("Reduce output records : " + js.getReduceOutputRecords());
457 assertEquals(count, js.getReduceOutputRecords());

Callers

nothing calls this directly

Calls 15

isMapredExecTypeMethod · 0.95
createInputFileMethod · 0.95
registerQueryMethod · 0.95
storeMethod · 0.95
getStatisticsMethod · 0.95
openMethod · 0.95
fullPathMethod · 0.95
getPigContextMethod · 0.95
getJobGraphMethod · 0.95
toStringMethod · 0.95
getMapInputRecordsMethod · 0.95
getMapOutputRecordsMethod · 0.95

Tested by

no test coverage detected