Package org.voltdb.plannodes

Examples of org.voltdb.plannodes.AbstractPlanNode


    public void testExtractColumnInfo() throws Exception {
        Procedure catalog_proc = this.getProcedure("SingleProjection");
        Statement catalog_stmt = this.getStatement(catalog_proc, "sql");
       
        // Grab the root node of the multi-partition query plan tree for this Statement
        AbstractPlanNode rootNode = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, false);
        PlanOptimizerUtil.populateTableNodeInfo(state, rootNode);
       
        // check two hashmaps contain what we expect
        checkPlanNodeColumns(state.planNodeColumns);
        checkTableColumns(state.tableColumns);
        System.out.println("Root Node: " + rootNode + " output columns: " + rootNode.getOutputColumnGUIDs() + " child type: " + rootNode.getChild(0).getPlanNodeType());
        // walk the tree and call extractColumnInfo on a rootNode
        new PlanNodeTreeWalker(true) {
            @Override
            protected void callback(AbstractPlanNode element) {
                // if (trace) LOG.trace(PlanNodeUtil.debugNode(element));
View Full Code Here


        ArrayList<AccessPath[]> listOfAccessPathCombos = generateAllAccessPathCombinationsForJoinOrder(joinOrder);

        // for each access path
        for (AccessPath[] accessPath : listOfAccessPathCombos) {
            // get a plan
            AbstractPlanNode scanPlan = getSelectSubPlanForAccessPath(joinOrder, accessPath);
            m_plans.add(scanPlan);
        }
    }
View Full Code Here

        // create copies of the tails of the joinOrder and accessPath arrays
        Table[] subJoinOrder = Arrays.copyOfRange(joinOrder, 1, joinOrder.length);
        AccessPath[] subAccessPath = Arrays.copyOfRange(accessPath, 1, accessPath.length);

        // recursively call this method to get the plan for the tail of the join order
        AbstractPlanNode subPlan = getSelectSubPlanForAccessPath(subJoinOrder, subAccessPath);

        // get all the clauses that join the applicable two tables
        ArrayList<AbstractExpression> joinClauses = accessPath[0].joinExprs;

        AbstractPlanNode nljAccessPlan = getAccessPlanForTable(joinOrder[0], accessPath[0]);

        /*
         * If the access plan for the table in the join order was for a
         * distributed table scan there will be a send/receive pair at the top.
         * The optimizations (nestloop, nestloopindex) that follow don't care
         * about the send/receive pair pop up the IndexScanPlanNode or
         * ScanPlanNode for them to work on.
         */
        boolean accessPlanIsSendReceive = false;
        AbstractPlanNode accessPlanTemp = nljAccessPlan;
        if (nljAccessPlan instanceof ReceivePlanNode) {
            accessPlanIsSendReceive = true;
            nljAccessPlan = nljAccessPlan.getChild(0).getChild(0);
            nljAccessPlan.clearParents();
        }

        AbstractPlanNode retval = null;
        if (nljAccessPlan instanceof IndexScanPlanNode) {
            NestLoopIndexPlanNode nlijNode = new NestLoopIndexPlanNode(m_context, PlanAssembler.getNextPlanNodeId());

            nlijNode.setJoinType(JoinType.INNER);

View Full Code Here

            throw compiler.new VoltCompilerException("Bad news! We don't have a last plan!!");
        }
        plan = last_plan;
       
        // HACK
        AbstractPlanNode root = null;
        try {
            root = PlanNodeUtil.getRootPlanNodeForStatement(catalogStmt, true);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here

        if (node instanceof UpdatePlanNode)
            return true;

        // recursively check out children
        for (int i = 0; i < node.getChildPlanNodeCount(); i++) {
            AbstractPlanNode child = node.getChild(i);
            if (fragmentReferencesPersistentTable(child))
                return true;
        }

        // if nothing found, return false
View Full Code Here

                        break;
                    }

                    // compute resource usage using the single stats collector
                    stats = new PlanStatistics();
                    AbstractPlanNode planGraph = plan.fragments.get(0).planGraph;
                   
                    // compute statistics about a plan
                    boolean result = planGraph.computeEstimatesRecursively(stats, m_cluster, m_db, m_estimates, paramHints);
                    assert(result);

                    // GENERATE JSON DEBUGGING OUTPUT BEFORE WE CLEAN UP THE PlanColumns
                    // convert a tree into an execution list
                    PlanNodeList nodeList = new PlanNodeList(planGraph);

                    // get the json serialized version of the plan
                    String json = "";
//                    try {
//                        String crunchJson = nodeList.toJSONString();
                        //System.out.println(crunchJson);
                        //System.out.flush();
                        /* FIXME
                        JSONObject jobj = new JSONObject(crunchJson);
                        json = jobj.toString(4);
                    } 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.
                        m_recentErrorMsg = "Plan for sql: '" + sql +
                                           "' can't be serialized to JSON";
                        return null;
                    }
                    */

                    // compute the cost based on the resources using the current cost model
                    double cost = costModel.getPlanCost(stats);

                    // find the minimum cost plan
                    if (cost < minCost) {
                        minCost = cost;
                        // free the PlanColumns held by the previous best plan
                        if (bestPlan != null) {
                            bestPlan.freePlan(m_context, plan.getColumnGuids());
                        }
                        bestPlan = plan;
                    } else {
                        plan.freePlan(m_context, bestPlan.getColumnGuids());
                    }

                    // output a description of the parsed stmt
                    String filename = String.valueOf(i++);
                    if (bestPlan == plan) winnerName = filename;
                    json = "COST: " + String.valueOf(cost) + "\n" + json;
                    planOutputs.put(filename, json);

                    // create a graph friendly version
                    dotPlanOutputs.put(filename, nodeList.toDOTString("name"));
                }
            }
            tpce_limit = null;
        }

        // make sure we got a winner
        if (bestPlan == null) {
            m_recentErrorMsg = "Unable to plan for statement. Error unknown.";
            return null;
        }

        // Validate that everything is there
        Set<Integer> bestPlan_columns = bestPlan.getColumnGuids();
        for (Integer column_guid : bestPlan_columns) {
            if (m_context.hasColumn(column_guid) == false) {
                m_recentErrorMsg = "Missing column guid " + column_guid;
                return (null);
            }
        } // FOR
        if (debug.val) LOG.debug(String.format("All columns are there for %s.%s: %s", procName, stmtName, bestPlan_columns));

        // reset all the plan node ids for a given plan
        bestPlan.resetPlanNodeIds();

        if (!m_quietPlanner)
        {
            // print all the plans to disk for debugging
            for (Entry<String, String> output : planOutputs.entrySet()) {
                String filename = output.getKey();
                if (winnerName.equals(filename)) {
                    filename = "WINNER " + filename;
                }
                PrintStream candidatePlanOut =
                    BuildDirectoryUtils.getDebugOutputPrintStream("statement-all-plans/" + procName + "_" + stmtName,
                                                                  filename + ".txt");

                candidatePlanOut.println(output.getValue());
                candidatePlanOut.close();
            }

            for (Entry<String, String> output : dotPlanOutputs.entrySet()) {
                String filename = output.getKey();
                if (winnerName.equals(filename)) {
                    filename = "WINNER " + filename;
                }
                PrintStream candidatePlanOut =
                    BuildDirectoryUtils.getDebugOutputPrintStream("statement-all-plans/" + procName + "_" + stmtName,
                                                                  filename + ".dot");

                candidatePlanOut.println(output.getValue());
                candidatePlanOut.close();
            }

            // output the plan statistics to disk for debugging
            PrintStream plansOut =
                BuildDirectoryUtils.getDebugOutputPrintStream("statement-stats", procName + "_" + stmtName + ".txt");
            plansOut.println(stats.toString());
            plansOut.close();
        }

        // PAVLO: Get the full plan json
        AbstractPlanNode root = bestPlan.fragments.get(0).planGraph;
//        String orig_debug = PlanNodeUtil.debug(root);
        assert(root != null);
        String json = null;
        try {
            JSONObject jobj = new JSONObject(new PlanNodeList(root).toJSONString());
View Full Code Here

    @Override
    public List<CompiledPlan> apply(CompiledPlan plan) {

        ArrayList<CompiledPlan> retval = new ArrayList<CompiledPlan>();

        AbstractPlanNode planGraph = plan.fragments.get(0).planGraph;
        planGraph.calculateDominators();

        List<AbstractPlanNode> receiveNodes =
            planGraph.findAllNodesOfType(PlanNodeType.RECEIVE);

        for (AbstractPlanNode pn : receiveNodes) {
            if (processReceiveNode(pn)) {

                // could make the graph transformation more complex
                // to avoid this recalculation; however, we expect graphs to
                // be relatively small and the total set of transformations
                // performed to also be small, making the cost of recalculation
                // an okay trade-off v. the complexity of a more efficient
                // implementation
                planGraph.calculateDominators();
            }
        }

        // modified plan in place
        retval.add(plan);
View Full Code Here

        // distinct must be an immediate parent of receive
        if (distinct.hasChild(receive) == false)
            return false;

        // distinct must have a single parent.
        AbstractPlanNode distinct_parent = distinct.getParent(0);
        if (distinct.getParentPlanNodeCount() > 1)
            return false;

        // receive must have a send child
        AbstractPlanNode send = receive.getChild(0);
        if (send.getPlanNodeType() != PlanNodeType.SEND) {
            assert(false) : "receive without send child?";
            return false;
        }

        // passes requirements to transform!

        // TODO: Determine if distinct.getDistinctColumnIndex() is a uniquely-valued column
        boolean distinct_on_unique_column = false;
        if (distinct_on_unique_column) {
            distinct.removeFromGraph();
            distinct_parent.addAndLinkChild(receive);
            send.addIntermediary(distinct);
        }
        else {
            assert(distinct.isInline() == false);
            DistinctPlanNode new_distinct = ((DistinctPlanNode)distinct).produceCopyForTransformation();
            send.addIntermediary(new_distinct);
        }
        return true;
    }
View Full Code Here

    @Override
    public List<CompiledPlan> apply(CompiledPlan plan) {
        ArrayList<CompiledPlan> retval = new ArrayList<CompiledPlan>();

        AbstractPlanNode planGraph = plan.fragments.get(0).planGraph;
        planGraph = recursivelyApply(planGraph);
        plan.fragments.get(0).planGraph = planGraph;

        retval.add(plan);
        return retval;
View Full Code Here

            return plan;

        if (plan.getChildPlanNodeCount() != 1)
            return plan;

        AbstractPlanNode child = plan.getChild(0);
        if ((child instanceof AbstractScanPlanNode) == false)
            return plan;

        plan.clearChildren();
        child.clearParents();
        child.addInlinePlanNode(plan);

        return child;
    }
View Full Code Here

TOP

Related Classes of org.voltdb.plannodes.AbstractPlanNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.