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

Method testInputCounters

test/org/apache/pig/test/TestCounters.java:623–684  ·  view source on GitHub ↗
(String keyword)

Source from the content-addressed store, hash-verified

621 private static int count = 0;
622
623 private void testInputCounters(String keyword) throws Exception {
624 String file1 = "multi-input1.txt";
625 String file2 = "multi-input2.txt";
626
627 String output = keyword;
628
629 if (keyword.equals("self-join")) {
630 file2 = file1;
631 keyword = "join";
632 }
633
634 final int MAX_NUM_RECORDS = 100;
635 if (!multiInputCreated) {
636 PrintWriter pw = new PrintWriter(Util.createInputFile(cluster, file1));
637 for (int i = 0; i < MAX_NUM_RECORDS; i++) {
638 int t = r.nextInt(100);
639 pw.println(t);
640 }
641 pw.close();
642
643 PrintWriter pw2 = new PrintWriter(Util.createInputFile(cluster, file2));
644 for (int i = 0; i < MAX_NUM_RECORDS; i++) {
645 int t = r.nextInt(100);
646 if (t > 50) {
647 count ++;
648 pw2.println(t);
649 }
650 }
651 pw2.close();
652 multiInputCreated = true;
653 }
654
655 PigServer pigServer = new PigServer(cluster.getExecType(),
656 cluster.getProperties());
657 pigServer.setBatchOn();
658 pigServer.registerQuery("a = load '" + file1 + "';");
659 pigServer.registerQuery("b = load '" + file2 + "';");
660 if (keyword.equals("join") || keyword.endsWith("cogroup")) {
661 pigServer.registerQuery("c = " + keyword + " a by $0, b by $0;");
662 } else if (keyword.equals("skewed")) {
663 pigServer.registerQuery("c = join a by $0, b by $0 using 'skewed';");
664 }
665 ExecJob job = pigServer.store("c", output + "_output");
666
667 PigStats stats = job.getStatistics();
668 assertTrue(stats.isSuccessful());
669 List<InputStats> inputs = stats.getInputStats();
670 if (keyword.equals("join") || keyword.endsWith("cogroup")) {
671 assertEquals(2, inputs.size());
672 } else if (keyword.equals("skewed")) {
673 assertEquals(3, inputs.size());
674 }
675 for (InputStats input : inputs) {
676 if (file1.equals(input.getName()) && input.getInputType() == InputStats.INPUT_TYPE.regular) {
677 assertEquals(MAX_NUM_RECORDS, input.getNumberRecords());
678 } else if (file2.equals(input.getName())){
679 assertEquals(count, input.getNumberRecords());
680 } else {

Callers 4

testJoinInputCountersMethod · 0.95

Calls 15

createInputFileMethod · 0.95
setBatchOnMethod · 0.95
registerQueryMethod · 0.95
storeMethod · 0.95
getStatisticsMethod · 0.95
isSuccessfulMethod · 0.95
getInputStatsMethod · 0.95
closeMethod · 0.65
sizeMethod · 0.65
equalsMethod · 0.45
nextIntMethod · 0.45
getExecTypeMethod · 0.45

Tested by

no test coverage detected