提交 8dca8598 编写于 作者: U uce

Add methods to get optimized plan from LocalExecutor

上级 eb797743
......@@ -23,6 +23,7 @@ import eu.stratosphere.pact.common.plan.PlanAssembler;
import eu.stratosphere.pact.compiler.DataStatistics;
import eu.stratosphere.pact.compiler.PactCompiler;
import eu.stratosphere.pact.compiler.plan.candidate.OptimizedPlan;
import eu.stratosphere.pact.compiler.plandump.PlanJSONDumpGenerator;
import eu.stratosphere.pact.compiler.plantranslate.NepheleJobGraphGenerator;
/**
......@@ -86,6 +87,26 @@ public class LocalExecutor {
}
}
/**
* Returns a JSON dump of the optimized plan.
*
* @param plan
* The program's plan.
* @return JSON dump of the optimized plan.
* @throws Exception
*/
public String getOptimizerPlanAsJSON(Plan plan) throws Exception {
if (this.nephele == null) {
throw new Exception("The local executor has not been started.");
}
PactCompiler pc = new PactCompiler(new DataStatistics());
OptimizedPlan op = pc.compile(plan);
PlanJSONDumpGenerator gen = new PlanJSONDumpGenerator();
return gen.getOptimizerPlanAsJSON(op);
}
/**
* Executes the program described by the given plan assembler.
*
......@@ -120,4 +141,28 @@ public class LocalExecutor {
}
}
}
/**
* Returns a JSON dump of the optimized plan.
*
* @param plan
* The program's plan.
* @return JSON dump of the optimized plan.
* @throws Exception
*/
public static String optimizerPlanAsJSON(Plan plan) throws Exception {
LocalExecutor exec = new LocalExecutor();
try {
exec.start();
PactCompiler pc = new PactCompiler(new DataStatistics());
OptimizedPlan op = pc.compile(plan);
PlanJSONDumpGenerator gen = new PlanJSONDumpGenerator();
return gen.getOptimizerPlanAsJSON(op);
} finally {
if (exec != null) {
exec.stop();
}
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册