* @param module
*/
@Override
public void notifyCodegenResult(Module module) {
if (opts.showRP) {
JobSpecification jobSpec = module.getHyracksJobSpecification();
try {
System.err.println(jobSpec.toJSON().toString(2));
} catch (JSONException e) {
e.printStackTrace();
System.err.println(jobSpec.toString());
}
}
}
/**
* On providing -showtet argument, output the syntax translation tree for the module in the format: "-- logical operator(if exists) | execution mode |"
* where execution mode can be one of: UNPARTITIONED,PARTITIONED,LOCAL
*
* @param module
*/
@Override
public void notifyTranslationResult(Module module) {
if (opts.showTET) {
System.err.println(appendPrettyPlan(new StringBuilder(), module).toString());
}
}
@Override
public void notifyTypecheckResult(Module module) {
}
/**
* On providing -showoet argument, output the optimized expression tree for the module in the format:
* "-- logical operator(if exists) | execution mode |" where execution mode can be one of: UNPARTITIONED,PARTITIONED,LOCAL
*
* @param module
*/
@Override
public void notifyOptimizedResult(Module module) {
if (opts.showOET) {
System.err.println(appendPrettyPlan(new StringBuilder(), module).toString());
}
}
/**
* On providing -showast argument, output the abstract syntax tree obtained from parsing by serializing the DomDriver object to a pretty-printed XML
* String.
*
* @param moduleNode
*/
@Override
public void notifyParseResult(ModuleNode moduleNode) {
if (opts.showAST) {
System.err.println(new XStream(new DomDriver()).toXML(moduleNode));
}
}
private StringBuilder appendPrettyPlan(StringBuilder sb, Module module) {
try {
ILogicalExpressionVisitor<String, Integer> ev = new VXQueryLogicalExpressionPrettyPrintVisitor(
module.getModuleContext());
LogicalOperatorPrettyPrintVisitor v = new LogicalOperatorPrettyPrintVisitor(ev);
PlanPrettyPrinter.printPlan(module.getBody(), sb, v, 0);
} catch (AlgebricksException e) {
e.printStackTrace();
}
return sb;
}
};
start = opts.timing ? new Date() : null;
XMLQueryCompiler compiler = new XMLQueryCompiler(listener, getNodeList(), opts.frameSize,
opts.availableProcessors, opts.joinHashSize);
resultSetId = createResultSetId();
CompilerControlBlock ccb = new CompilerControlBlock(new StaticContextImpl(RootStaticContextImpl.INSTANCE),
resultSetId, null);
compiler.compile(query, new StringReader(qStr), ccb, opts.optimizationLevel);
// if -timing argument passed, show the starting and ending times
if (opts.timing) {
end = new Date();
timingMessage("Compile time: " + (end.getTime() - start.getTime()) + " ms");
}
if (opts.compileOnly) {
continue;
}
Module module = compiler.getModule();
JobSpecification js = module.getHyracksJobSpecification();
DynamicContext dCtx = new DynamicContextImpl(module.getModuleContext());
js.setGlobalJobDataFactory(new VXQueryGlobalDataFactory(dCtx.createFactory()));
PrintWriter writer = new PrintWriter(System.out, true);
// Repeat execution for number of times provided in -repeatexec argument
for (int i = 0; i < opts.repeatExec; ++i) {
start = opts.timing ? new Date() : null;