Package org.voltdb.planner

Examples of org.voltdb.planner.PlannerContext


     * @param node
     * @param exps
     * @return
     */
    public static Collection<AbstractExpression> getExpressionsForPlanNode(AbstractPlanNode node, Set<AbstractExpression> exps, PlanNodeType... exclude) {
        final PlannerContext plannerContext = PlannerContext.singleton();
        final PlanNodeType node_type = node.getPlanNodeType();
        for (PlanNodeType e : exclude) {
            if (node_type == e)
                return (exps);
        } // FOR

        switch (node_type) {
            // ---------------------------------------------------
            // SCANS
            // ---------------------------------------------------
            case INDEXSCAN: {
                IndexScanPlanNode idx_node = (IndexScanPlanNode) node;
                if (idx_node.getEndExpression() != null)
                    exps.add(idx_node.getEndExpression());
                for (AbstractExpression exp : idx_node.getSearchKeyExpressions()) {
                    if (exp != null)
                        exps.add(exp);
                } // FOR

                // Fall through down into SEQSCAN....
            }
            case SEQSCAN: {
                AbstractScanPlanNode scan_node = (AbstractScanPlanNode) node;
                if (scan_node.getPredicate() != null)
                    exps.add(scan_node.getPredicate());
                break;
            }
            // ---------------------------------------------------
            // JOINS
            // ---------------------------------------------------
            case NESTLOOP:
            case NESTLOOPINDEX: {
                AbstractJoinPlanNode cast_node = (AbstractJoinPlanNode) node;
                if (cast_node.getPredicate() != null)
                    exps.add(cast_node.getPredicate());

                // We always need to look at the inline scan nodes for joins
                for (AbstractPlanNode inline_node : cast_node.getInlinePlanNodes().values()) {
                    if (inline_node instanceof AbstractScanPlanNode) {
                        PlanNodeUtil.getExpressionsForPlanNode(inline_node, exps);
                    }
                } // FOR
                break;
            }
            // ---------------------------------------------------
            // PROJECTION
            // ---------------------------------------------------
            case MATERIALIZE:
            case PROJECTION: {
                for (Integer col_guid : node.getOutputColumnGUIDs()) {
                    PlanColumn col = plannerContext.get(col_guid);
                    assert (col != null) : "Invalid PlanColumn #" + col_guid;
                    if (col.getExpression() != null)
                        exps.add(col.getExpression());
                } // FOR
                break;
            }
            // ---------------------------------------------------
            // AGGREGATE
            // ---------------------------------------------------
            case AGGREGATE:
            case HASHAGGREGATE: {
                AggregatePlanNode agg_node = (AggregatePlanNode) node;
                for (Integer col_guid : agg_node.getAggregateColumnGuids()) {
                    PlanColumn col = plannerContext.get(col_guid);
                    assert (col != null) : "Invalid PlanColumn #" + col_guid;
                    if (col.getExpression() != null)
                        exps.add(col.getExpression());
                } // FOR
                for (Integer col_guid : agg_node.getGroupByColumnGuids()) {
                    PlanColumn col = plannerContext.get(col_guid);
                    assert (col != null) : "Invalid PlanColumn #" + col_guid;
                    if (col.getExpression() != null)
                        exps.add(col.getExpression());
                } // FOR
                break;
            }
            // ---------------------------------------------------
            // ORDERBY
            // ---------------------------------------------------
            case ORDERBY: {
                OrderByPlanNode orby_node = (OrderByPlanNode) node;
                for (Integer col_guid : orby_node.getSortColumnGuids()) {
                    PlanColumn col = plannerContext.get(col_guid);
                    assert (col != null) : "Invalid PlanColumn #" + col_guid;
                    if (col.getExpression() != null)
                        exps.add(col.getExpression());
                } // FOR
                break;
View Full Code Here


     * @param catalog_db
     * @param node
     * @return
     */
    public static Collection<Column> getOutputColumnsForPlanNode(final Database catalog_db, AbstractPlanNode node) {
        final PlannerContext pcontext = PlannerContext.singleton();
        final Collection<Integer> planColumnIds = getOutputColumnIdsForPlanNode(node);

        final Set<Column> columns = new ListOrderedSet<Column>();
        for (Integer column_guid : planColumnIds) {
            PlanColumn planColumn = pcontext.get(column_guid);
            assert (planColumn != null);
            AbstractExpression exp = planColumn.getExpression();
            assert (exp != null);
            Collection<Column> exp_cols = ExpressionUtil.getReferencedColumns(catalog_db, exp);
            if (debug.val)
View Full Code Here

     * @param catalogContext
     * @param node
     * @return
     */
    public static Collection<AbstractExpression> getOutputExpressionsForPlanNode(AbstractPlanNode node) {
        final PlannerContext pcontext = PlannerContext.singleton();
        final Collection<Integer> planColumnIds = getOutputColumnIdsForPlanNode(node);

        final Collection<AbstractExpression> exps = new ListOrderedSet<AbstractExpression>();
        for (Integer column_guid : planColumnIds) {
            PlanColumn planColumn = pcontext.get(column_guid);
            assert (planColumn != null);
            AbstractExpression exp = planColumn.getExpression();
            assert (exp != null);
            exps.add(exp);
        } // FOR
View Full Code Here

            Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
            ret = new ListOrderedSet<Column>();
            try {
                AbstractPlanNode root = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
                assert (root != null);
                PlannerContext context = PlannerContext.singleton();
                for (OrderByPlanNode node : PlanNodeUtil.getPlanNodes(root, OrderByPlanNode.class)) {
                    for (Integer guid : node.getSortColumnGuids()) {
                        PlanColumn pcol = context.get(guid);
                        assert (pcol != null);
                        ret.addAll(ExpressionUtil.getReferencedColumns(catalog_db, pcol.getExpression()));
                    } // FOR
                } // FOR
            } catch (Throwable ex) {
View Full Code Here

                    assert (proj_node != null);

                    // This is a bit tricky. We have to go by the names of the
                    // output columns to find what
                    // column is meant to be updated
                    PlannerContext pcontext = PlannerContext.singleton();
                    for (Integer col_guid : proj_node.getOutputColumnGUIDs()) {
                        PlanColumn pc = pcontext.get(col_guid);
                        assert (pc != null);
                        if (pc.getExpression() instanceof TupleAddressExpression)
                            continue;

                        Column catalog_col = catalog_tbl.getColumns().get(pc.getDisplayName());
View Full Code Here

        // output columns in their topmost send node
        AbstractPlanNode spRoot = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
        assertNotNull(spRoot);
       
        assertEquals(root.getOutputColumnGUIDCount(), spRoot.getOutputColumnGUIDCount());
        PlannerContext context = PlannerContext.singleton();
        assertNotNull(context);
        for (int i = 0, cnt = root.getOutputColumnGUIDCount(); i < cnt; i++) {
            Integer guid0 = root.getOutputColumnGUID(i);
            PlanColumn col0 = context.get(guid0);
            assertNotNull(col0);
           
            Integer guid1 = spRoot.getOutputColumnGUID(i);
            PlanColumn col1 = context.get(guid1);
            assertNotNull(col1);
           
            assertTrue(col0.equals(col1, false, true));
        } // FOR
       
View Full Code Here

   
    /**
     * testGetPlanNodes
     */
    public void testGetPlanNodes() throws Exception {
        PlannerContext cntxt = new PlannerContext();
        AbstractPlanNode root_node = new ProjectionPlanNode(cntxt, 1);
        root_node.addAndLinkChild(new SeqScanPlanNode(cntxt, 2));
       
        Collection<SeqScanPlanNode> found0 = PlanNodeUtil.getPlanNodes(root_node, SeqScanPlanNode.class);
        assertFalse(found0.isEmpty());
View Full Code Here

TOP

Related Classes of org.voltdb.planner.PlannerContext

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.