// Create the canonical plan ...
long start = System.nanoTime();
PlanNode plan = planner.createPlan(context, query);
long duration = System.nanoTime() - start;
Statistics stats = new Statistics(duration);
QueryResultColumns resultColumns = QueryResultColumns.empty();
if (!context.getProblems().hasErrors()) {
// Optimize the plan ...
start = System.nanoTime();
PlanNode optimizedPlan = optimizer.optimize(context, plan);
duration = System.nanoTime() - start;
stats = stats.withOptimizationTime(duration);
// Find the query result columns ...
start = System.nanoTime();
resultColumns = determineQueryResultColumns(optimizedPlan, context.getHints());
duration = System.nanoTime() - start;
stats = stats.withOptimizationTime(duration);
if (!context.getProblems().hasErrors()) {
// Execute the plan ...
try {
start = System.nanoTime();
return processor.execute(context, query, stats, optimizedPlan);
} finally {
duration = System.nanoTime() - start;
stats = stats.withOptimizationTime(duration);
}
}
}
// There were problems somewhere ...
return new org.jboss.dna.graph.query.process.QueryResults(resultColumns, stats, context.getProblems());