本文整理汇总了Java中org.apache.pig.tools.pigstats.PigStats.isSuccessful方法的典型用法代码示例。如果您正苦于以下问题:Java PigStats.isSuccessful方法的具体用法?Java PigStats.isSuccessful怎么用?Java PigStats.isSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.tools.pigstats.PigStats
的用法示例。
在下文中一共展示了PigStats.isSuccessful方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runEmbeddedScript
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
private static int runEmbeddedScript(PigContext pigContext, String file, String engine)
throws IOException {
log.info("Run embedded script: " + engine);
pigContext.connect();
ScriptEngine scriptEngine = ScriptEngine.getInstance(engine);
Map<String, List<PigStats>> statsMap = scriptEngine.run(pigContext, file);
PigStatsUtil.setStatsMap(statsMap);
int failCount = 0;
int totalCount = 0;
for (List<PigStats> lst : statsMap.values()) {
if (lst != null && !lst.isEmpty()) {
for (PigStats stats : lst) {
if (!stats.isSuccessful()) failCount++;
totalCount++;
}
}
}
return (totalCount > 0 && failCount == totalCount) ? ReturnCode.FAILURE
: (failCount > 0) ? ReturnCode.PARTIAL_FAILURE
: ReturnCode.SUCCESS;
}
示例2: verifyImportUsingSearchPath
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
private boolean verifyImportUsingSearchPath(String macroFilePath, String importFilePath,
String importSearchPath, boolean createMacroFilePath) throws Exception {
if (createMacroFilePath) {
createFile(macroFilePath, groupAndCountMacro);
}
String script =
"import '" + importFilePath + "';\n" +
"alpha = load 'users' as (user, age, zip);\n" +
"gamma = group_and_count (alpha, user, 23);\n" +
"store gamma into 'byuser';\n";
createFile("myscript.pig", script);
String[] args = {
(importSearchPath != null ? "-Dpig.import.search.path=" + importSearchPath : ""),
"-x", "local", "-c", "myscript.pig"
};
PigStats stats = PigRunner.run(args, null);
return stats.isSuccessful();
}
示例3: runEmbeddedScript
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
private static int runEmbeddedScript(PigContext pigContext, String file, String engine)
throws IOException {
log.info("Run embedded script: " + engine);
pigContext.connect();
ScriptEngine scriptEngine = ScriptEngine.getInstance(engine);
Map<String, List<PigStats>> statsMap = scriptEngine.run(pigContext, file);
PigStatsUtil.setStatsMap(statsMap);
int failCount = 0;
int totalCount = 0;
for (List<PigStats> lst : statsMap.values()) {
if (lst != null && !lst.isEmpty()) {
for (PigStats stats : lst) {
if (!stats.isSuccessful()) failCount++;
totalCount++;
}
}
}
return (totalCount > 0 && failCount == totalCount) ? ReturnCode.FAILURE
: (failCount > 0) ? ReturnCode.PARTIAL_FAILURE
: ReturnCode.SUCCESS;
}
示例4: get
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
/**
*
* @param location
* @return the data in this location
*/
public List<Tuple> get(String location) {
if (!locationToData.containsKey(location)) {
PigStats pigStats = PigStats.get();
boolean successful = pigStats.isSuccessful();
throw new RuntimeException("No data for location '" + location + "'." + (successful ? "" : " It seems the job has failled, check logs"));
}
return locationToData.get(location).getAll();
}
示例5: verify
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
private void verify(String s, String expected) throws Exception {
createFile("myscript.pig", s);
String[] args = { "-Dpig.import.search.path=/tmp", "-x", "local", "-c", "myscript.pig" };
PigStats stats = PigRunner.run(args, null);
if (!stats.isSuccessful()) {
System.out.println("error msg: " + stats.getErrorMessage());
}
assertTrue(stats.isSuccessful());
String[] args2 = { "-Dpig.import.search.path=/tmp", "-x", "local", "-r", "myscript.pig" };
PigRunner.run(args2, null);
File f2 = new File("myscript.pig.expanded");
BufferedReader br = new BufferedReader(new FileReader(f2));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line).append("\n");
line = br.readLine();
}
f2.delete();
if (expected != null) {
Assert.assertEquals(expected, sb.toString());
} else {
System.out.println("Result:\n" + sb.toString());
}
}
示例6: verify
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
private void verify(String s, String expected) throws Exception {
createFile("myscript.pig", s);
String[] args = { "-Dpig.import.search.path=/tmp", "-x", "local", "-c", "myscript.pig" };
PigStats stats = PigRunner.run(args, null);
if (!stats.isSuccessful()) {
System.out.println("error msg: " + stats.getErrorMessage());
}
assertTrue(stats.isSuccessful());
String[] args2 = { "-Dpig.import.search.path=/tmp", "-x", "local", "-r", "myscript.pig" };
PigRunner.run(args2, null);
File f2 = new File("myscript.pig.expanded");
BufferedReader br = new BufferedReader(new FileReader(f2));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line).append("\n");
line = br.readLine();
}
f2.delete();
if (expected != null) {
Assert.assertEquals(expected, sb.toString());
} else {
System.out.println("Result:\n" + sb.toString());
}
}
示例7: store
import org.apache.pig.tools.pigstats.PigStats; //导入方法依赖的package包/类
/**
* Executes a Pig Latin script up to and including indicated alias and stores the resulting
* records into a file. That is, if a user does:
* <pre>
* PigServer server = new PigServer();
* server.registerQuery("A = load 'foo';");
* server.registerQuery("B = filter A by $0 > 0;");
* server.registerQuery("C = order B by $1;");
* </pre>
* Then
* <pre>
* server.store("B", "bar", "mystorefunc");
* </pre>
* filtered but unsorted data will be stored to the file <tt>bar</tt> using
* <tt>mystorefunc</tt>. If instead a user does
* <pre>
* server.store("C", "bar", "mystorefunc");
* </pre>
* filtered and sorted data will be stored to the file <tt>bar</tt> using
* <tt>mystorefunc</tt>.
* <p>
* @param id The alias to store
* @param filename The file to which to store to
* @param func store function to use
* @return {@link ExecJob} containing information about this job
* @throws IOException
*/
public ExecJob store(String id, String filename, String func)
throws IOException {
PigStats stats = storeEx(id, filename, func);
if (stats.getOutputStats().size() < 1) {
throw new IOException("Couldn't retrieve job.");
}
OutputStats output = stats.getOutputStats().get(0);
if(stats.isSuccessful()){
return new HJob(JOB_STATUS.COMPLETED, pigContext, output
.getPOStore(), output.getAlias(), stats);
}else{
HJob job = new HJob(JOB_STATUS.FAILED, pigContext,
output.getPOStore(), output.getAlias(), stats);
//check for exception
Exception ex = null;
for(JobStats js : stats.getJobGraph()){
if(js.getException() != null) {
ex = js.getException();
}
}
job.setException(ex);
return job;
}
}