Package org.voltdb.plannodes

Examples of org.voltdb.plannodes.AbstractPlanNode


        for (AbstractPlanNode inNode : node.getInlinePlanNodes().values()) {
            inNode.overrideId(nextId++);
        }

        for (int i = 0; i < node.getChildPlanNodeCount(); i++) {
            AbstractPlanNode child = node.getChild(i);
            assert(child != null);
            nextId = resetPlanNodeIds(child, nextId);
        }
        return nextId;
    }
View Full Code Here


        } // FOR

        // Skip single partition query plans
        // if (types.contains(PlanNodeType.RECEIVE) == false) return (null);

        AbstractPlanNode new_root = root;
        if (trace.val)
            LOG.trace("BEFORE: " + sql + "\n" + StringBoxUtil.box(PlanNodeUtil.debug(root)));
//             LOG.debug("LET 'ER RIP!");
//         }
View Full Code Here

    }

    private AbstractPlanNode getNextSelectPlan() {
        assert (subAssembler != null);

        AbstractPlanNode subSelectRoot = subAssembler.nextPlan();
        if (subSelectRoot == null)
            return null;

        AbstractPlanNode root = subSelectRoot;

        /*
         * Establish the output columns for the sub select plan.
         * The order, aggregation and expression operations placed
         * "on top" of this work should calculate correct output
         * column state as nodes are added. (That is,
         * the recursive updateOutputColumns() ideally wouldn't
         * have other callers.)
         */
        root.updateOutputColumns(m_catalogDb);

        // PAVLO: Ok so now before this just assumed that we were going to stick a AggregatePlanNode on top
        // of the root that we sent it (which should be a AbstractScanPlanNode or a ReceievePlanNode).
        // But now because we are trying to impress John Hugg (and who isn't really?), we may actually perform
        // part of the aggregation at the remote partitions, so we need a buttom up approach for cleaning
        // up the PlanColumns...
        root = handleAggregationOperators(root);
       
//        if (PlanNodeUtil.getPlanNodes(root, ReceivePlanNode.class).isEmpty() == false) {
//            LOG.debug("PAVLO OPTIMIZATION:\n" + PlanNodeUtil.debug(root));
//        }
         root.updateOutputColumns(m_catalogDb);

        if ((subSelectRoot.getPlanNodeType() != PlanNodeType.INDEXSCAN ||
            ((IndexScanPlanNode) subSelectRoot).getSortDirection() == SortDirectionType.INVALID) &&
            m_parsedSelect.orderColumns.size() > 0) {
            root = addOrderBy(root);
        }

        if ((root.getPlanNodeType() != PlanNodeType.AGGREGATE) &&
            (root.getPlanNodeType() != PlanNodeType.HASHAGGREGATE) &&
            (root.getPlanNodeType() != PlanNodeType.DISTINCT) &&
            (root.getPlanNodeType() != PlanNodeType.PROJECTION)) {
            root = addProjection(root);
        }

        if ((m_parsedSelect.limit != -1) || (m_parsedSelect.limitParameterId != -1) ||
            (m_parsedSelect.offset > 0) || (m_parsedSelect.offsetParameterId != -1))
        {
            LimitPlanNode limit = new LimitPlanNode(m_context, getNextPlanNodeId());
            limit.setLimit((int) m_parsedSelect.limit);
            limit.setOffset((int) m_parsedSelect.offset);

            if (m_parsedSelect.offsetParameterId != -1) {
                ParameterInfo parameterInfo =
                    m_parsedSelect.paramsById.get(m_parsedSelect.offsetParameterId);
                limit.setOffsetParameterIndex(parameterInfo.index);
            }
            if (m_parsedSelect.limitParameterId != -1) {
                ParameterInfo parameterInfo =
                    m_parsedSelect.paramsById.get(m_parsedSelect.limitParameterId);
                limit.setLimitParameterIndex(parameterInfo.index);
            }
            limit.addAndLinkChild(root);
            limit.setOutputColumns(root.getOutputColumnGUIDs());
            root = limit;
        }
       
//        System.out.println(PlanNodeUtil.debug(root));
//        System.out.println();
//        System.out.println();
       
//        System.err.println(m_parsedSelect.sql);
        PlanOptimizer po = new PlanOptimizer(m_context, m_catalogDb);
        AbstractPlanNode new_root = po.optimize(m_parsedSelect.sql, root);
       
//        if (root.getPlanNodeType().equals(PlanNodeType.PROJECTION) && PlanNodeUtil.getDepth(root) == 0) {
//            System.out.println("Root node type: " + root.getPlanNodeType());
//            System.out.println("Depth: " + PlanNodeUtil.getDepth(root));
//            System.out.println(PlanNodeUtil.debug(root));
//            System.out.println();
//            System.out.println();                       
//        }
       
        SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
        // check if there is a new root + connect the nodes to build the graph
        if (new_root != null) {
            sendNode.addAndLinkChild(new_root);
            sendNode.setOutputColumns(new_root.getOutputColumnGUIDs());           
        } else {
            sendNode.addAndLinkChild(root);
            sendNode.setOutputColumns(root.getOutputColumnGUIDs());                       
        }
       
View Full Code Here

                        + targetTable.getTypeName() + "'";
            msg += " in a single-partition procedure.";
            throw new PlanningErrorException(msg);
        }

        AbstractPlanNode subSelectRoot = subAssembler.nextPlan();
        if (subSelectRoot == null)
            return null;

        // generate the delete node with the right target table
        DeletePlanNode deleteNode = new DeletePlanNode(m_context, getNextPlanNodeId());
        deleteNode.setTargetTableName(targetTable.getTypeName());

        ProjectionPlanNode projectionNode = new ProjectionPlanNode(m_context, getNextPlanNodeId());
        AbstractExpression addressExpr = new TupleAddressExpression();
        PlanColumn colInfo = m_context.getPlanColumn(addressExpr, "tuple_address");
        projectionNode.appendOutputColumn(colInfo);

        if (m_singlePartition == true) {

            assert(subSelectRoot instanceof AbstractScanPlanNode);

            // if the scan below matches all nodes, we can throw away the scan
            // nodes and use a truncate delete node
            if ((subSelectRoot instanceof SeqScanPlanNode)
                    && (((AbstractScanPlanNode) subSelectRoot).getPredicate() == null)) {
                deleteNode.setTruncate(true);
                return deleteNode;
            }

            // OPTIMIZATION: Projection Inline
            // If the root node we got back from createSelectTree() is an
            // AbstractScanNode, then
            // we put the Projection node we just created inside of it
            subSelectRoot.addInlinePlanNode(projectionNode);
            // connect the nodes to build the graph
            deleteNode.addAndLinkChild(subSelectRoot);

            // XXX: PAVLO
            if (INCLUDE_SEND_FOR_ALL) {
                SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
                sendNode.setFake(true);
                sendNode.addAndLinkChild(deleteNode);
                sendNode.setOutputColumns(deleteNode.getOutputColumnGUIDs());
                return sendNode;
            } else {
                return deleteNode;
            }
        } else {
            // make sure the thing we have is a receive node which
            // indicates it's a multi-site plan
            assert (subSelectRoot instanceof ReceivePlanNode);

            //
            // put the delete node in the right place
            //

            // get the recv node
            ReceivePlanNode recvNode = (ReceivePlanNode) subSelectRoot;
            // get the send node
            assert (recvNode.getChildPlanNodeCount() == 1);
            AbstractPlanNode sendNode = recvNode.getChild(0);

            // get the scan node and unlink
            assert (sendNode.getChildPlanNodeCount() == 1);
            AbstractPlanNode scanNode = sendNode.getChild(0);
            sendNode.unlinkChild(scanNode);

            // link in the delete node
            assert (scanNode instanceof AbstractScanPlanNode);
            scanNode.addInlinePlanNode(projectionNode);
            deleteNode.addAndLinkChild(scanNode);

            AbstractPlanNode combineNode = insertCountInDMLPlan(deleteNode);
            sendNode.addAndLinkChild(combineNode);

            // fix the receive node's output columns
            recvNode.updateOutputColumns(m_catalogDb);
            /*
 
View Full Code Here

                        + "'";
            msg += " in a single-partition procedure.";
            throw new PlanningErrorException(msg);
        }

        AbstractPlanNode subSelectRoot = subAssembler.nextPlan();
        if (subSelectRoot == null)
            return null;

        UpdatePlanNode updateNode = new UpdatePlanNode(m_context, getNextPlanNodeId());
        updateNode.setTargetTableName(targetTable.getTypeName());
        // set this to false until proven otherwise
        updateNode.setUpdateIndexes(false);

        ProjectionPlanNode projectionNode = new ProjectionPlanNode(m_context, getNextPlanNodeId());
        TupleAddressExpression tae = new TupleAddressExpression();
        PlanColumn colInfo = m_context.getPlanColumn(tae, "tuple_address");
        projectionNode.appendOutputColumn(colInfo);

        // get the set of columns affected by indexes
        Set<String> affectedColumns = getIndexedColumnSetForTable(targetTable);

        // add the output columns we need
        for (Entry<Column, AbstractExpression> col : m_parsedUpdate.columns.entrySet()) {
            colInfo = m_context.getPlanColumn(col.getValue(), col.getKey().getTypeName());
            projectionNode.appendOutputColumn(colInfo);

            // check if this column is an indexed column
            if (affectedColumns.contains(colInfo.getDisplayName()))
                updateNode.setUpdateIndexes(true);
        }

        if (m_singlePartition == true) {

            // add the projection inline (TODO: this will break if more than one
            // layer is below this)
            assert(subSelectRoot instanceof AbstractScanPlanNode);
            subSelectRoot.addInlinePlanNode(projectionNode);

            // connect the nodes to build the graph
            updateNode.addAndLinkChild(subSelectRoot);

            // XXX: PAVLO
            if (INCLUDE_SEND_FOR_ALL) {
                SendPlanNode sendNode = new SendPlanNode(m_context, getNextPlanNodeId());
                sendNode.setFake(true);
                sendNode.addAndLinkChild(updateNode);
                sendNode.setOutputColumns(updateNode.getOutputColumnGUIDs());
                return sendNode;
            } else {
                return updateNode;
            }
           
        } else {
            // make sure the thing we have is a receive node which
            // indicates it's a multi-site plan
            assert (subSelectRoot instanceof ReceivePlanNode);

            //
            // put the update node in the right place
            //

            // get the recv node
            ReceivePlanNode recvNode = (ReceivePlanNode) subSelectRoot;
            // get the send node
            assert (recvNode.getChildPlanNodeCount() == 1);
            AbstractPlanNode sendNode = recvNode.getChild(0);

            // get the scan node and unlink
            assert (sendNode.getChildPlanNodeCount() == 1);
            AbstractPlanNode scanNode = sendNode.getChild(0);
            sendNode.unlinkChild(scanNode);

            // link in the update node
            assert (scanNode instanceof AbstractScanPlanNode);
            scanNode.addInlinePlanNode(projectionNode);
            updateNode.addAndLinkChild(scanNode);

            AbstractPlanNode countNode = insertCountInDMLPlan(updateNode);
            sendNode.addAndLinkChild(countNode);

            // fix the receive node's output columns
            recvNode.updateOutputColumns(m_catalogDb);
            /*
 
View Full Code Here

            materializeNode.appendOutputColumn(colInfo);
        }

        // connect the insert and the materialize nodes together
        insertNode.addAndLinkChild(materializeNode);
        AbstractPlanNode rootNode = insertNode;

        if (m_singlePartition == false) {
            // all sites to a scan -> send
            // root site has many recvs feeding into a union
            rootNode = insertCountInDMLPlan(rootNode);
View Full Code Here

                for (String f : copy_src_frag.getFields()) {
                    assertEquals(f, copy_src_frag.getField(f), copy_dest_frag.getField(f));
                } // FOR

                AbstractPlanNode src_root = PlanNodeUtil.getPlanNodeTreeForPlanFragment(copy_src_frag);
                assertNotNull(copy_src_frag.fullName(), src_root);
                AbstractPlanNode dest_root = PlanNodeUtil.getPlanNodeTreeForPlanFragment(copy_dest_frag);
                assertNotNull(copy_src_frag.fullName(), dest_root);
                //
                // System.err.println(StringUtil.columns(PlanNodeUtil.debug(src_root),
                // PlanNodeUtil.debug(dest_root)));
            }
View Full Code Here

    public void testExtractPlanNodeColumnSet() throws Exception {
        Procedure catalog_proc = this.getProcedure(slev.class);
        assertNotNull(catalog_proc);
        Statement catalog_stmt = catalog_proc.getStatements().get("GetStockCount");

        AbstractPlanNode root_node = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
        assertNotNull(root_node);
        // System.out.println(PlanNodeUtil.debug(root_node));

        PredicatePairs cset = new PredicatePairs();
        Table tables[] = new Table[] {
View Full Code Here

import org.voltdb.types.JoinType;

public class TestMultipleOuterJoinPlans  extends PlannerTestCase {

    public void testInnerOuterJoin() {
        AbstractPlanNode pn = compile("select * FROM R1 INNER JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R2.C");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
View Full Code Here

        assertTrue(JoinType.INNER == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
    }

    public void testOuterOuterJoin() {
        AbstractPlanNode pn = compile("select * FROM R1 LEFT JOIN R2 ON R1.A = R2.A LEFT JOIN R3 ON R3.C = R1.C");
        AbstractPlanNode n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        NestLoopPlanNode nlj = (NestLoopPlanNode) n;
        assertTrue(JoinType.LEFT == nlj.getJoinType());
        assertTrue(nlj.getJoinPredicate() != null);
        n = nlj.getChild(0);
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.