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

Method testCount

test/org/apache/pig/test/TestBZip.java:463–501  ·  view source on GitHub ↗
(String inputFileName, Long expectedCount,
            int splitSize, String loadFuncSpec)

Source from the content-addressed store, hash-verified

461 }
462
463 private void testCount(String inputFileName, Long expectedCount,
464 int splitSize, String loadFuncSpec) throws IOException {
465 String outputFile = "/tmp/bz-output";
466 // simple load-store script to verify that the bzip input is getting
467 // split
468 String scriptToTestSplitting = "a = load '" +inputFileName + "' using " +
469 loadFuncSpec + "; store a into '" + outputFile + "';";
470
471 String script = "a = load '" + inputFileName + "';" +
472 "b = group a all;" +
473 "c = foreach b generate COUNT_STAR(a);";
474 Properties props = new Properties();
475 for (Entry<Object, Object> entry : properties.entrySet()) {
476 props.put(entry.getKey(), entry.getValue());
477 }
478 props.setProperty(MRConfiguration.MAX_SPLIT_SIZE, Integer.toString(splitSize));
479 props.setProperty("pig.noSplitCombination", "true");
480 PigServer pig = new PigServer(cluster.getExecType(), props);
481 FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration(props));
482 fs.delete(new Path(outputFile), true);
483 Util.registerMultiLineQuery(pig, scriptToTestSplitting);
484
485 // verify that > 1 maps were launched due to splitting of the bzip input
486 FileStatus[] files = fs.listStatus(new Path(outputFile));
487 int numPartFiles = 0;
488 for (FileStatus fileStatus : files) {
489 if(fileStatus.getPath().getName().startsWith("part")) {
490 numPartFiles++;
491 }
492 }
493 assertEquals(true, numPartFiles > 1);
494
495 // verify record count to verify we read bzip data correctly
496 Util.registerMultiLineQuery(pig, script);
497 Iterator<Tuple> it = pig.openIterator("c");
498 Long result = (Long) it.next().get(0);
499 assertEquals(expectedCount, result);
500
501 }
502
503 @Test
504 public void testBzipStoreInMultiQuery() throws Exception {

Calls 15

toConfigurationMethod · 0.95
openIteratorMethod · 0.95
entrySetMethod · 0.80
getValueMethod · 0.65
setPropertyMethod · 0.65
getMethod · 0.65
deleteMethod · 0.65
putMethod · 0.45
getKeyMethod · 0.45
toStringMethod · 0.45
getExecTypeMethod · 0.45

Tested by

no test coverage detected