本文整理汇总了Java中org.apache.pig.tools.pigstats.PigStats.getAllStats方法的典型用法代码示例。如果您正苦于以下问题:Java PigStats.getAllStats方法的具体用法?Java PigStats.getAllStats怎么用?Java PigStats.getAllStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.tools.pigstats.PigStats
的用法示例。
在下文中一共展示了PigStats.getAllStats方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pigRunnerTest
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void pigRunnerTest() throws Exception {
String[] script = {
"from org.apache.pig.scripting import *",
"Pig.fs(\"rmr simple_out\")",
"input = 'simple_table_2'",
"output = 'simple_out'",
"P = Pig.compile(\"\"\"a = load '$input';store a into '$output';\"\"\")",
"Q = P.bind({'input':input, 'output':output})",
"stats = Q.runSingle()",
"if stats.isSuccessful():",
"\tprint 'success!'",
"else:",
"\traise 'failed'"
};
String[] input = {
"1\t3",
"2\t4",
"3\t5"
};
Util.createInputFile(cluster, "simple_table_2", input);
PigStats mainStats = runPigRunner("pigRunnerTest", script);
Map<String, List<PigStats>> statsMap = mainStats.getAllStats();
assertEquals(1, statsMap.size());
Iterator<List<PigStats>> it = statsMap.values().iterator();
PigStats stats = it.next().get(0);
assertTrue("job should succeed", stats.isSuccessful());
assertEquals(1, stats.getNumberJobs());
String name = stats.getOutputNames().get(0);
assertEquals("simple_out", name);
assertEquals(12, stats.getBytesWritten());
assertEquals(3, stats.getRecordWritten());
}
示例2: runParallelTest
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void runParallelTest() throws Exception {
String[] script = {
"#!/usr/bin/python",
"from org.apache.pig.scripting import *",
"input = 'simple_table_3'",
"Pig.fs(\"rmr simple_out\")",
"Pig.fs(\"rmr simple_out2\")",
"output1 = 'simple_out'",
"output2 = 'simple_out2'",
"P = Pig.compile(\"mypipeline\", \"\"\"a = load '$input';store a into '$output';\"\"\")",
"Q = P.bind([{'input':input, 'output':output1}, {'input':input, 'output':output2}])",
"stats = Q.run()"
};
String[] input = {
"1\t3",
"2\t4",
"3\t5"
};
Util.createInputFile(cluster, "simple_table_3", input);
PigStats mainStats = runPigRunner("runParallelTest", script);
Map<String, List<PigStats>> statsMap = mainStats.getAllStats();
assertEquals(1, statsMap.size());
assertEquals("mypipeline", statsMap.keySet().iterator().next());
List<PigStats> lst = statsMap.get("mypipeline");
assertEquals(2, lst.size());
for (PigStats stats : lst) {
assertTrue("job should succeed", stats.isSuccessful());
assertEquals(1, stats.getNumberJobs());
assertEquals(12, stats.getBytesWritten());
assertEquals(3, stats.getRecordWritten());
}
}
示例3: runLoopTest
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void runLoopTest() throws Exception {
String[] script = {
"#!/usr/bin/python",
"from org.apache.pig.scripting import *",
"Pig.fs(\"rmr simple_out\")",
"Pig.fs(\"rmr simple_out2\")",
"input = 'simple_table_4'",
"P = Pig.compile(\"mypipeline\", \"\"\"a = load '$input';store a into '$output';\"\"\")",
"for x in [\"simple_out\", \"simple_out2\"]:",
"\tQ = P.bind({'input':input, 'output':x}).run()"
};
String[] input = {
"1\t3",
"2\t4",
"3\t5"
};
Util.createInputFile(cluster, "simple_table_4", input);
PigStats mainStats = runPigRunner("runLoopTest", script);
Map<String, List<PigStats>> statsMap = mainStats.getAllStats();
assertEquals(1, statsMap.size());
assertEquals("mypipeline", statsMap.keySet().iterator().next());
List<PigStats> lst = statsMap.get("mypipeline");
assertEquals(2, lst.size());
for (PigStats stats : lst) {
assertTrue("job should succeed", stats.isSuccessful());
assertEquals(1, stats.getNumberJobs());
assertEquals(12, stats.getBytesWritten());
assertEquals(3, stats.getRecordWritten());
}
}
示例4: runParallelTest2
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
@Test
public void runParallelTest2() throws Exception {
String[] script = {
"#!/usr/bin/python",
"from org.apache.pig.scripting import *",
"input = 'simple_table_7'",
"Pig.fs(\"rmr simple_out\")",
"Pig.fs(\"rmr simple_out2\")",
"output1 = 'simple_out'",
"output2 = 'simple_out2'",
"P = Pig.compile(\"mypipeline\", \"\"\"a = load '$input';",
"b = foreach a generate $0, org.apache.pig.test.utils.UDFContextTestEvalFunc3($0);",
"store b into '$output';\"\"\")",
"Q = P.bind([{'input':input, 'output':output1}, {'input':input, 'output':output2}])",
"stats = Q.run()"
};
String[] input = {
"1\t3"
};
Util.createInputFile(cluster, "simple_table_7", input);
PigStats mainStats = runPigRunner("runParallelTest2", script);
Map<String, List<PigStats>> statsMap = mainStats.getAllStats();
assertEquals(1, statsMap.size());
assertEquals("mypipeline", statsMap.keySet().iterator().next());
List<PigStats> lst = statsMap.get("mypipeline");
assertEquals(2, lst.size());
String[] results = new String[2];
int i = 0;
for (PigStats stats : lst) {
assertTrue("job should succeed", stats.isSuccessful());
assertEquals(1, stats.getNumberJobs());
OutputStats os = stats.getOutputStats().get(0);
Tuple t = os.iterator().next();
results[i++] = t.get(1).toString();
}
assertTrue(results[0] != null);
assertTrue(results[1] != null);
assertTrue(!results[0].equals(results[1]));
}