Package org.voltdb.plannodes

Examples of org.voltdb.plannodes.AbstractScanPlanNode


        if (debug.val) {
            LOG.debug("LIMIT:    " + PlanNodeUtil.debug(limit_node));
            LOG.debug("ORDER BY: " + PlanNodeUtil.debug(orderby_node));
            LOG.debug(PlanNodeUtil.getPlanNodes(root, AbstractScanPlanNode.class));
        }
        AbstractScanPlanNode scan_node = CollectionUtil.first(PlanNodeUtil.getPlanNodes(root, AbstractScanPlanNode.class));
        assert (scan_node != null) : "Unexpected PlanTree:\n" + PlanNodeUtil.debug(root);
        SendPlanNode send_node = (SendPlanNode) scan_node.getParent(0);
        assert (send_node != null);

        send_node.addIntermediary(limit_node);
        if (orderby_node != null) {
            limit_node.addIntermediary(orderby_node);
            // Need to make sure that the LIMIT has the proper output columns
            limit_node.setOutputColumns(orderby_node.getOutputColumnGUIDs());
            state.markDirty(orderby_node);
        } else {
            // Need to make sure that the LIMIT has the proper output columns
            limit_node.setOutputColumns(scan_node.getOutputColumnGUIDs());
        }
        state.markDirty(limit_node);
        if (debug.val)
            LOG.debug("PLANOPT - Added " + limit_node + " after " + scan_node);
View Full Code Here


        assertNotNull(root);
       
        // First check that our single scan node has an inline Projection
        Collection<AbstractScanPlanNode> scan_nodes = PlanNodeUtil.getPlanNodes(root, AbstractScanPlanNode.class);
        assertEquals(1, scan_nodes.size());
        AbstractScanPlanNode scan_node = CollectionUtil.first(scan_nodes);
        assertNotNull(scan_node);
        assertEquals(1, scan_node.getInlinePlanNodes().size());
        assertNotNull(scan_node.getInlinePlanNodes().get(PlanNodeType.PROJECTION));
       
        // Now check to make sure there are no other Projections in the tree
//        Set<ProjectionPlanNode> proj_nodes = PlanNodeUtil.getPlanNodes(root, ProjectionPlanNode.class);
//        assertEquals(0, proj_nodes.size());
    }
View Full Code Here

        assertNotNull(root);
       
        // Check that our single scan node has a COUNT AggregatePlanNode above it.
        Collection<AbstractScanPlanNode> scan_nodes = PlanNodeUtil.getPlanNodes(root, AbstractScanPlanNode.class);
        assertEquals(1, scan_nodes.size());
        AbstractScanPlanNode scan_node = CollectionUtil.first(scan_nodes);
        assertNotNull(scan_node);
        assertEquals(1, scan_node.getParentPlanNodeCount());
        // FIXME assertEquals(PlanNodeType.AGGREGATE, scan_node.getParent(0).getPlanNodeType());
        // FIXME AggregatePlanNode count_node = (AggregatePlanNode)scan_node.getParent(0);
        // FIXME assertNotNull(count_node);
        // FIXME assert(count_node.getAggregateTypes().contains(ExpressionType.AGGREGATE_COUNT));
       
View Full Code Here

                        // check the inline scan node's column offsets are based
                        // on the "mashing" of the intermediate table
                        // and the target scan table
                        assert (element.getInlinePlanNodes().size() == 1) : "More than 1 Inline Nodes in NestLoopIndex";
                        assert (element.getInlinePlanNode(PlanNodeType.INDEXSCAN) != null || element.getInlinePlanNode(PlanNodeType.SEQSCAN) != null) : "No scan nodes exist in inline plan nodes";
                        AbstractScanPlanNode scan_node = (AbstractScanPlanNode) CollectionUtil.first(element.getInlinePlanNodes().values());
                        // get all columns of the "target table" being scanned
                        // and append them to the current intermediate table
                        // + determine new offsets + determine new guids
                        Map<String, Integer> scan_node_map = buildTableMap(scan_node);
                        Integer intermediate_tbl_offset = intermediate_offset_tbl.size();
                        for (Map.Entry<String, Integer> col : scan_node_map.entrySet()) {
                            intermediate_offset_tbl.put(col.getKey(), intermediate_tbl_offset + col.getValue());
                        }
                        for (Integer col_guid : scan_node.getOutputColumnGUIDs()) {
                            PlanColumn plan_col = PlannerContext.singleton().get(col_guid);
                            intermediate_GUID_tbl.put(plan_col.getDisplayName(), plan_col.guid());
                        }
                        // check that expression column offsets + output column
                        // offsets match + GUIDs match with the original target
View Full Code Here

        AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, false);
        assertNotNull(root);
        // First check that our single scan node has an inline Projection
        Collection<AbstractScanPlanNode> scan_nodes = PlanNodeUtil.getPlanNodes(root, AbstractScanPlanNode.class);
        assertEquals(1, scan_nodes.size());
        AbstractScanPlanNode scan_node = CollectionUtil.first(scan_nodes);
        assertNotNull(scan_node);
        assertEquals(1, scan_node.getInlinePlanNodes().size());

        // Get the Projection and make sure it has valid output columns
        ProjectionPlanNode inline_proj = (ProjectionPlanNode) scan_node.getInlinePlanNodes().get(PlanNodeType.PROJECTION);
        assertNotNull(inline_proj);
        for (int column_guid : inline_proj.getOutputColumnGUIDs()) {
            PlanColumn column = PlannerContext.singleton().get(column_guid);
            // System.err.println(String.format("[%02d] %s", column_guid,
            // column));
View Full Code Here

        // we need to join are included. Note that we don't care which table is
        // scanned first, as we can
        // dynamically figure things out for ourselves
        Collection<AbstractScanPlanNode> scan_nodes = PlanNodeUtil.getPlanNodes(root, AbstractScanPlanNode.class);
        assertEquals(1, scan_nodes.size());
        AbstractScanPlanNode scan_node = CollectionUtil.first(scan_nodes);
        assertNotNull(scan_node);
        Table catalog_tbl = this.getTable(scan_node.getTargetTableName());

        assertEquals(1, scan_node.getInlinePlanNodes().size());
        ProjectionPlanNode inline_proj = (ProjectionPlanNode) scan_node.getInlinePlanNodes().get(PlanNodeType.PROJECTION);
        assertNotNull(inline_proj);

        // Validate output columns
        for (int column_guid : inline_proj.getOutputColumnGUIDs()) {
            PlanColumn column = PlannerContext.singleton().get(column_guid);
View Full Code Here

    public void testScanJoinConditions() {
        AbstractPlanNode pn = compile("select * FROM R1 WHERE R1.C = 0");
        AbstractPlanNode n = pn.getChild(0);
        assertTrue(n instanceof AbstractScanPlanNode);
        AbstractScanPlanNode scan = (AbstractScanPlanNode) n;
        AbstractExpression p = scan.getPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());

        pn = compile("select * FROM R1, R2 WHERE R1.A = R2.A AND R1.C > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        n = n.getChild(0);
        assertTrue(n instanceof AbstractScanPlanNode);
        assertTrue(((AbstractScanPlanNode) n).getTargetTableName().equalsIgnoreCase("R1"));
        p = ((AbstractScanPlanNode) n).getPredicate();
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());

        pn = compile("select * FROM R1, R2 WHERE R1.A = R2.A AND R1.C > R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.CONJUNCTION_AND, p.getExpressionType());
        if (p.getLeft().getExpressionType() == ExpressionType.COMPARE_EQUAL) {
            assertEquals(ExpressionType.COMPARE_EQUAL, p.getLeft().getExpressionType());
            assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getRight().getExpressionType());
        } else {
            assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getLeft().getExpressionType());
            assertEquals(ExpressionType.COMPARE_EQUAL, p.getRight().getExpressionType());
        }
        assertNull(((AbstractScanPlanNode)n.getChild(0)).getPredicate());
        assertNull(((AbstractScanPlanNode)n.getChild(1)).getPredicate());

        pn = compile("select * FROM R1 JOIN R2 ON R1.A = R2.A WHERE R1.C > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        n = n.getChild(0);
        assertTrue(n instanceof AbstractScanPlanNode);
        assertTrue("R1".equalsIgnoreCase(((AbstractScanPlanNode) n).getTargetTableName()));
        p = ((AbstractScanPlanNode) n).getPredicate();
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());

        pn = compile("select * FROM R1 JOIN R2 ON R1.A = R2.A WHERE R1.C > R2.C");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.CONJUNCTION_AND, p.getExpressionType());
        if (ExpressionType.COMPARE_EQUAL == p.getLeft().getExpressionType()) {
            assertEquals(ExpressionType.COMPARE_EQUAL, p.getLeft().getExpressionType());
            assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getRight().getExpressionType());
        } else {
            assertEquals(ExpressionType.COMPARE_LESSTHAN, p.getLeft().getExpressionType());
            assertEquals(ExpressionType.COMPARE_EQUAL, p.getRight().getExpressionType());
        }
        assertNull(((AbstractScanPlanNode)n.getChild(0)).getPredicate());
        assertNull(((AbstractScanPlanNode)n.getChild(1)).getPredicate());

        pn = compile("select * FROM R1, R2, R3 WHERE R1.A = R2.A AND R1.C = R3.C AND R1.A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        AbstractPlanNode c = n.getChild(0);
        assertTrue(c instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) c).getJoinPredicate();
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getExpressionType());
        c = c.getChild(0);
        assertTrue(c instanceof AbstractScanPlanNode);
        p = ((AbstractScanPlanNode) c).getPredicate();
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());
        c = n.getChild(1);
        assertTrue("R3".equalsIgnoreCase(((AbstractScanPlanNode) c).getTargetTableName()));
        assertEquals(null, ((AbstractScanPlanNode) c).getPredicate());

        pn = compile("select * FROM R1 JOIN R2 on R1.A = R2.A AND R1.C = R2.C where R1.A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.CONJUNCTION_AND, p.getExpressionType());
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getLeft().getExpressionType());
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getRight().getExpressionType());
        n = n.getChild(0);
        assertTrue(n instanceof AbstractScanPlanNode);
        assertTrue("R1".equalsIgnoreCase(((AbstractScanPlanNode) n).getTargetTableName()));
        p = ((AbstractScanPlanNode) n).getPredicate();
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, p.getExpressionType());

        pn = compile("select A,C FROM R1 JOIN R2 USING (A, C)");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.CONJUNCTION_AND, p.getExpressionType());
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getLeft().getExpressionType());
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getRight().getExpressionType());

        pn = compile("select A,C FROM R1 JOIN R2 USING (A, C) WHERE A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof AbstractJoinPlanNode);
        p = ((AbstractJoinPlanNode) n).getJoinPredicate();
        assertEquals(ExpressionType.CONJUNCTION_AND, p.getExpressionType());
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getLeft().getExpressionType());
        assertEquals(ExpressionType.COMPARE_EQUAL, p.getRight().getExpressionType());
        n = n.getChild(1);
        assertTrue(n instanceof AbstractScanPlanNode);
        scan = (AbstractScanPlanNode) n;
        assertTrue(scan.getPredicate() != null);
        assertEquals(ExpressionType.COMPARE_GREATERTHAN, scan.getPredicate().getExpressionType());

        pn = compile("select * FROM R1 JOIN R2 ON R1.A = R2.A JOIN R3 ON R1.C = R3.C WHERE R1.A > 0");
        n = pn.getChild(0).getChild(0);
        assertTrue(n instanceof NestLoopPlanNode);
        p = ((NestLoopPlanNode) n).getJoinPredicate();
View Full Code Here

        int size2 = list2.size();
        int max = Math.max(size1, size2);
        int min = Math.min(size1, size2);
        diffPair intdiffPair = new diffPair(0,0);
        ArrayList<String> messages = new ArrayList<String>();
        AbstractScanPlanNode spn1 = null;
        AbstractScanPlanNode spn2 = null;
        if( max == 0 ) {
            messages.add("0 scan statement");
        }
        else {
            if( size1 != size2 ){
View Full Code Here

        // MV table scan node can not be in in-lined nodes.
        for (int i = 0; i < node.getChildCount(); i++) {
            AbstractPlanNode child = node.getChild(i);

            if (child instanceof AbstractScanPlanNode) {
                AbstractScanPlanNode scanNode = (AbstractScanPlanNode) child;
                if (!scanNode.getTargetTableName().equals(getMVTableName())) {
                    continue;
                }
                if (reAggNode != null) {
                    // Join query case.
                    node.setAndLinkChild(i, reAggNode);
                }
                // Process scan node.
                // Set up the scan plan node's scan columns. Add in-line projection node for scan node.
                scanNode.addInlinePlanNode(m_scanInlinedProjectionNode);
                m_scanNode = scanNode;
                return true;
            } else {
                boolean replaced = processScanNodeWithReAggNode(child, reAggNode);
                if (replaced) {
View Full Code Here

     * @param initial plan
     * @return A complete plan tree for the entire SQl.
     */
    private AbstractPlanNode connectChildrenBestPlans(AbstractPlanNode parentPlan) {
        if (parentPlan instanceof AbstractScanPlanNode) {
            AbstractScanPlanNode scanNode = (AbstractScanPlanNode) parentPlan;
            StmtTableScan tableScan = scanNode.getTableScan();
            if (tableScan instanceof StmtSubqueryScan) {
                CompiledPlan betsCostPlan = ((StmtSubqueryScan)tableScan).getBestCostPlan();
                assert (betsCostPlan != null);
                AbstractPlanNode subQueryRoot = betsCostPlan.rootPlanGraph;
                subQueryRoot.disconnectParents();
                scanNode.addAndLinkChild(subQueryRoot);
            }
        } else {
            for (int i = 0; i < parentPlan.getChildCount(); ++i) {
                connectChildrenBestPlans(parentPlan.getChild(i));
            }
View Full Code Here

TOP

Related Classes of org.voltdb.plannodes.AbstractScanPlanNode

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.