2021SC@SDUSC
总览
本次分析主要针对的是DryRunGruntParser类。DryRunGruntParse类主要是用来实现org.apache.pig.tools.pigscript.parser.PigScriptParser类的方法的类。读入数据流,结合数据流的所处环境对数据流进行分析得到其数据。
代码分析
初始化
初始化为一个读入的数据流,以及他的来源,还有当前对象在程序中所处的一个环境,一个与系统交互的过程。stream对象是一组支持串行并行聚合操作的元素,也可以理解成集合或者迭代器的增强版。
public DryRunGruntParser(Reader stream, String source, PigContext context) {
super(stream);
this.source = source;
this.context = context;
}
processExplain()
该方法实现了对进程的解释,通过读入别名,形式,目标等数据,通过判断数据是否为空来判断该进程的状态。
protected void processExplain(String alias, String script,
boolean isVerbose, String format, String target,
List<String> params, List<String> files) throws IOException,
ParseException {
sb.append("explain ");
if (script != null) {
sb.append("-script ").append(script).append(" ");
}
if (target != null) {
sb.append("-out ").append(target).append(" ");
}
if (isVerbose) sb.append("-brief ");
if (format != null && format.equals("dot")) {
sb.append("-dot ");
}
if (format != null && format.equals("xml")) {
sb.append("-xml ");
}
if (params != null) {
for (String param : params) {
sb.append("-param ").append(param).append