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

Method testMapOnlyBinStorage

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

Source from the content-addressed store, hash-verified

113 }
114
115 @Test
116 public void testMapOnlyBinStorage() throws IOException, ExecException {
117 int count = 0;
118 PrintWriter pw = new PrintWriter(Util.createInputFile(cluster, file));
119 for(int i = 0; i < MAX; i++) {
120 int t = r.nextInt(100);
121 pw.println(t);
122 if(t > 50)
123 count ++;
124 }
125 pw.close();
126 PigServer pigServer = new PigServer(cluster.getExecType(), cluster.getProperties());
127 pigServer.registerQuery("a = load '" + file + "';");
128 pigServer.registerQuery("b = filter a by $0 > 50;");
129 pigServer.registerQuery("c = foreach b generate $0 - 50;");
130 ExecJob job = pigServer.store("c", "output_map_only", "BinStorage");
131 PigStats pigStats = job.getStatistics();
132
133 InputStream is = FileLocalizer.open(FileLocalizer.fullPath(
134 "output_map_only", pigServer.getPigContext()),
135 pigServer.getPigContext());
136
137 long filesize = 0;
138 while(is.read() != -1) filesize++;
139
140 is.close();
141
142 cluster.getFileSystem().delete(new Path(file), true);
143 cluster.getFileSystem().delete(new Path("output_map_only"), true);
144
145 System.out.println("============================================");
146 System.out.println("Test case Map Only");
147 System.out.println("============================================");
148
149 JobGraph jp = pigStats.getJobGraph();
150 Iterator<JobStats> iter = jp.iterator();
151 while (iter.hasNext()) {
152 JobStats js = iter.next();
153
154 System.out.println("Map input records : " + js.getMapInputRecords());
155 assertEquals(MAX, js.getMapInputRecords());
156 System.out.println("Map output records : " + js.getMapOutputRecords());
157 assertEquals(count, js.getMapOutputRecords());
158 assertEquals(0, js.getReduceInputRecords());
159 assertEquals(0, js.getReduceOutputRecords());
160 }
161
162 System.out.println("Hdfs bytes written : " + pigStats.getBytesWritten());
163 assertEquals(filesize, pigStats.getBytesWritten());
164 }
165
166 @Test
167 public void testMapReduceOnly() throws IOException, ExecException {

Callers

nothing calls this directly

Calls 15

createInputFileMethod · 0.95
registerQueryMethod · 0.95
storeMethod · 0.95
getStatisticsMethod · 0.95
openMethod · 0.95
fullPathMethod · 0.95
getPigContextMethod · 0.95
getJobGraphMethod · 0.95
iteratorMethod · 0.95
getMapInputRecordsMethod · 0.95
getMapOutputRecordsMethod · 0.95
getReduceInputRecordsMethod · 0.95

Tested by

no test coverage detected