use of org.voltdb.plannodes.PlanNodeTree in project voltdb by VoltDB.
the class AdHocPlannedStmtBatch method explainStatement.
/**
* Return the "EXPLAIN" string of the batched statement at the index
* @param i the index
* @param db the database context (for adding catalog details).
*/
public String explainStatement(int i, Database db) {
AdHocPlannedStatement plannedStatement = plannedStatements.get(i);
String aggplan = new String(plannedStatement.core.aggregatorFragment, Constants.UTF8ENCODING);
PlanNodeTree pnt = new PlanNodeTree();
try {
JSONObject jobj = new JSONObject(aggplan);
pnt.loadFromJSONPlan(jobj, db);
if (plannedStatement.core.collectorFragment != null) {
// multi-partition query plan
String collplan = new String(plannedStatement.core.collectorFragment, Constants.UTF8ENCODING);
PlanNodeTree collpnt = new PlanNodeTree();
// reattach plan fragments
JSONObject jobMP = new JSONObject(collplan);
collpnt.loadFromJSONPlan(jobMP, db);
assert (collpnt.getRootPlanNode() instanceof SendPlanNode);
pnt.getRootPlanNode().reattachFragment(collpnt.getRootPlanNode());
}
String result = pnt.getRootPlanNode().toExplainPlanString();
return result;
} catch (JSONException e) {
System.out.println(e);
return "Internal Error (JSONException): " + e.getMessage();
}
}
use of org.voltdb.plannodes.PlanNodeTree in project voltdb by VoltDB.
the class MaterializedViewProcessor method getPlanNodeTreeFromCatalogStatement.
private PlanNodeTree getPlanNodeTreeFromCatalogStatement(Database db, Statement stmt) {
PlanNodeTree pnt = new PlanNodeTree();
try {
JSONObject jsonPlan = new JSONObject(org.voltdb.utils.Encoder.decodeBase64AndDecompress(stmt.getFragments().get("0").getPlannodetree()));
pnt.loadFromJSONPlan(jsonPlan, db);
} catch (JSONException e) {
e.printStackTrace();
}
return pnt;
}
Aggregations