Search in sources :

Example 1 with PlanNodeList

use of org.voltdb.plannodes.PlanNodeList in project voltdb by VoltDB.

the class TestPushDownAggregates method testLimit.

public void testLimit() {
    List<AbstractPlanNode> pn = compileToFragments("select PKEY from T1 order by PKEY limit 5");
    PlanNodeList pnl = new PlanNodeList(pn.get(0));
    System.out.println(pnl.toDOTString("FRAG0"));
    pnl = new PlanNodeList(pn.get(1));
    System.out.println(pnl.toDOTString("FRAG1"));
}
Also used : AbstractPlanNode(org.voltdb.plannodes.AbstractPlanNode) PlanNodeList(org.voltdb.plannodes.PlanNodeList)

Example 2 with PlanNodeList

use of org.voltdb.plannodes.PlanNodeList in project voltdb by VoltDB.

the class StatementCompiler method writePlanBytes.

/**
     * Update the plan fragment and return the bytes of the plan
     */
static byte[] writePlanBytes(VoltCompiler compiler, PlanFragment fragment, AbstractPlanNode planGraph) throws VoltCompilerException {
    String json = null;
    // get the plan bytes
    PlanNodeList node_list = new PlanNodeList(planGraph);
    json = node_list.toJSONString();
    compiler.captureDiagnosticJsonFragment(json);
    // Place serialized version of PlanNodeTree into a PlanFragment
    byte[] jsonBytes = json.getBytes(Charsets.UTF_8);
    String bin64String = Encoder.compressAndBase64Encode(jsonBytes);
    fragment.setPlannodetree(bin64String);
    return jsonBytes;
}
Also used : PlanNodeList(org.voltdb.plannodes.PlanNodeList)

Example 3 with PlanNodeList

use of org.voltdb.plannodes.PlanNodeList in project voltdb by VoltDB.

the class PlanSelector method outputPlanDebugString.

public static String outputPlanDebugString(AbstractPlanNode planGraph) throws JSONException {
    PlanNodeList nodeList = new PlanNodeList(planGraph);
    // get the json serialized version of the plan
    String json = null;
    String crunchJson = nodeList.toJSONString();
    //System.out.println(crunchJson);
    //System.out.flush();
    JSONObject jobj = new JSONObject(crunchJson);
    json = jobj.toString(4);
    return json;
}
Also used : JSONObject(org.json_voltpatches.JSONObject) PlanNodeList(org.voltdb.plannodes.PlanNodeList)

Example 4 with PlanNodeList

use of org.voltdb.plannodes.PlanNodeList in project voltdb by VoltDB.

the class StatementCompiler method writePlanBytes.

/**
     * Update the plan fragment and return the bytes of the plan
     */
static byte[] writePlanBytes(PlanFragment fragment, AbstractPlanNode planGraph) {
    // get the plan bytes
    PlanNodeList node_list = new PlanNodeList(planGraph);
    String json = node_list.toJSONString();
    // Place serialized version of PlanNodeTree into a PlanFragment
    byte[] jsonBytes = json.getBytes(Charsets.UTF_8);
    String bin64String = Encoder.compressAndBase64Encode(jsonBytes);
    fragment.setPlannodetree(bin64String);
    return jsonBytes;
}
Also used : PlanNodeList(org.voltdb.plannodes.PlanNodeList)

Example 5 with PlanNodeList

use of org.voltdb.plannodes.PlanNodeList in project voltdb by VoltDB.

the class PlanSelector method outputPlanFullDebug.

/**
     * @param plan
     * @param planGraph
     * @param filename
     * @return error message if any
     */
private String outputPlanFullDebug(CompiledPlan plan, AbstractPlanNode planGraph, String filename) {
    // GENERATE JSON DEBUGGING OUTPUT BEFORE WE CLEAN UP THE
    // PlanColumns
    // convert a tree into an execution list
    PlanNodeList nodeList = new PlanNodeList(planGraph);
    String json;
    try {
        json = outputPlanDebugString(planGraph);
    } catch (JSONException e2) {
        // Any plan that can't be serialized to JSON to
        // write to debugging output is also going to fail
        // to get written to the catalog, to sysprocs, etc.
        // Just bail.
        String errorMsg = "Plan for sql: '" + plan.sql + "' can't be serialized to JSON";
        // For now, just skip the output and go on to the next plan.
        return errorMsg;
    }
    // output a description of the parsed stmt
    json = "PLAN:\n" + json;
    json = "COST: " + String.valueOf(plan.cost) + "\n" + json;
    assert (plan.sql != null);
    json = "SQL: " + plan.sql + "\n" + json;
    // write json to disk
    BuildDirectoryUtils.writeFile("statement-all-plans/" + m_procName + "_" + m_stmtName, filename + "-json.txt", json, true);
    // create a graph friendly version
    BuildDirectoryUtils.writeFile("statement-all-plans/" + m_procName + "_" + m_stmtName, filename + ".dot", nodeList.toDOTString("name"), true);
    return null;
}
Also used : JSONException(org.json_voltpatches.JSONException) PlanNodeList(org.voltdb.plannodes.PlanNodeList)

Aggregations

PlanNodeList (org.voltdb.plannodes.PlanNodeList)6 JSONException (org.json_voltpatches.JSONException)2 JSONObject (org.json_voltpatches.JSONObject)2 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)2 ArrayList (java.util.ArrayList)1 Statement (org.voltdb.catalog.Statement)1 StmtParameter (org.voltdb.catalog.StmtParameter)1 DatabaseEstimates (org.voltdb.compiler.DatabaseEstimates)1 ParameterValueExpression (org.voltdb.expressions.ParameterValueExpression)1 QueryType (org.voltdb.types.QueryType)1