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

Method testEmptyBzipInPig

test/org/apache/pig/test/TestBZip.java:317–351  ·  view source on GitHub ↗

Tests the end-to-end writing and reading of an empty BZip file.

()

Source from the content-addressed store, hash-verified

315 * Tests the end-to-end writing and reading of an empty BZip file.
316 */
317 @Test
318 public void testEmptyBzipInPig() throws Exception {
319 PigServer pig = new PigServer(cluster.getExecType(), properties);
320
321 File in = folder.newFile("junit-in.tmp");
322
323 File out = folder.newFile("junit-out.bz2");
324 out.delete();
325 String clusterOutputFilePath = Util.removeColon(out.getAbsolutePath());
326
327 FileOutputStream fos = new FileOutputStream(in);
328 fos.write("55\n".getBytes());
329 fos.close();
330 System.out.println(in.getAbsolutePath());
331
332 pig.registerQuery("AA = load '"
333 + Util.generateURI(in.getAbsolutePath(), pig.getPigContext())
334 + "';");
335 pig.registerQuery("A=foreach (group (filter AA by $0 < '0') all) generate flatten($1);");
336 pig.registerQuery("store A into '" + Util.encodeEscape(clusterOutputFilePath) + "';");
337 FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(
338 pig.getPigContext().getProperties()));
339 FileStatus[] outputFiles = fs.listStatus(new Path(clusterOutputFilePath),
340 Util.getSuccessMarkerPathFilter());
341 FSDataInputStream is = fs.open(outputFiles[0].getPath());
342 CBZip2InputStream cis = new CBZip2InputStream(is, -1, out.length());
343
344 // Just a sanity check, to make sure it was a bzip file; we
345 // will do the value verification later
346 assertEquals(-1, cis.read(new byte[100]));
347 cis.close();
348
349 pig.registerQuery("B = load '" + Util.encodeEscape(clusterOutputFilePath) + "';");
350 pig.openIterator("B");
351 }
352
353 /**
354 * Tests the writing and reading of an empty BZip file.

Callers

nothing calls this directly

Calls 15

removeColonMethod · 0.95
registerQueryMethod · 0.95
generateURIMethod · 0.95
getPigContextMethod · 0.95
encodeEscapeMethod · 0.95
toConfigurationMethod · 0.95
readMethod · 0.95
closeMethod · 0.95
openIteratorMethod · 0.95
getAbsolutePathMethod · 0.80
lengthMethod · 0.80

Tested by

no test coverage detected