Package org.voltdb.planner

Examples of org.voltdb.planner.PlanColumn


        // 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));
            // System.err.println("==================");
            // System.err.println(PlannerContext.singleton().debug());
            assertNotNull("Invalid PlanColumn [guid=" + column_guid + "]", column);
            assertEquals(column_guid, column.guid());
        } // FOR

        // Now check to make sure there are no other Projections in the tree
        Collection<ProjectionPlanNode> proj_nodes = PlanNodeUtil.getPlanNodes(root, ProjectionPlanNode.class);
        assertEquals(0, proj_nodes.size());
View Full Code Here


        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
       

        new PlanNodeTreeWalker() {

            @Override
            protected void callback(AbstractPlanNode element) {
                // System.out.println("element plannodetype: " +
                // element.getPlanNodeType() + " depth: " + this.getDepth());
            }
        }.traverse(root);
        //
        // System.err.println("+++++++++++++++++++++++++++++++++++++++++++++++++++");
        //
        // System.err.println(PlanNodeUtil.debug(root));
        // //
        //
        // System.err.println("+++++++++++++++++++++++++++++++++++++++++++++++++++");
        // //
        // // System.err.println("# of Fragments: " +
        // catalog_stmt.getMs_fragments().size());
        // // for (PlanFragment pf : catalog_stmt.getMs_fragments()) {
        // // System.err.println(pf.getName() + "\n" +
        // PlanNodeUtil.debug(QueryPlanUtil.deserializePlanFragment(pf)));
        // }

        // At the very bottom of our tree should be a scan. Grab that and then
        // check to see that it has an inline ProjectionPlanNode. We will then
        // look to see whether
        // all of the columns
        // 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);
            assertNotNull("Missing PlanColumn [guid=" + column_guid + "]", column);
            assertEquals(column_guid, column.guid());

            // Check that only columns from the scanned table are there
            String table_name = column.originTableName();
            assertNotNull(table_name);
            String column_name = column.originColumnName();
            assertNotNull(column_name);
            assertEquals(table_name + "." + column_name, catalog_tbl.getName(), table_name);
            assertNotNull(table_name + "." + column_name, catalog_tbl.getColumns().get(column_name));
        } // FOR
View Full Code Here

            }
            final String exprTableName = expr.getTableName();
            final String columnName = expr.getColumnName();
            int ii = 0;
            for (Integer colGuid : outputColumns) {
                PlanColumn info = context.get(colGuid);
                if (info.originTableName().equals(exprTableName)) {
                    if (info.getDisplayName().equals(columnName)) {
                        expr.setColumnIndex(ii);
                        return;
                    }
                }
                ii++;
View Full Code Here

            final TupleValueExpression expr = (TupleValueExpression) input;
            final String tableName = expr.getTableName();
            final String columnName = expr.getColumnName();
            int ii = 0;
            for (Integer colGuid : outputColumns) {
                PlanColumn info = context.get(colGuid);
                if (info.originTableName().equals(tableName)) {
                    if (info.getDisplayName().equals(columnName)) {
                        expr.setColumnIndex(ii);
                        return;
                    }
                }
                ii++;
View Full Code Here

        }

        // Output Columns
        int index = 0;
        for (Integer colguid : plan.columns) {
            PlanColumn planColumn = planner.getPlannerContext().get(colguid);
            Column catColumn = catalogStmt.getOutput_columns().add(planColumn.getDisplayName()); // String.valueOf(index));
            catColumn.setNullable(false);
            catColumn.setIndex(index);
//            catColumn.setName(planColumn.displayName());
            catColumn.setType(planColumn.type().getValue());
            catColumn.setSize(planColumn.width());
            index++;
        }

        catalogStmt.setReplicatedtabledml(plan.replicatedTableDML);
View Full Code Here

     * @param orig_pc
     * @param output_cols
     * @return
     */
    protected static Pair<PlanColumn, Integer> findMatchingColumn(final PlanOptimizerState state, PlanColumn orig_pc, List<Integer> output_cols) {
        PlanColumn new_pc = null;
        int new_idx = 0;
        for (Integer new_guid : output_cols) {
            new_pc = state.plannerContext.get(new_guid);
            assert (new_pc != null) : "Unexpected PlanColumn #" + new_guid;

            if (new_pc.equals(orig_pc, true, true)) {
                if (trace.val)
                    LOG.trace(String.format("[%02d] Found non-expression PlanColumn match:\nORIG: %s\nNEW: %s", new_idx, orig_pc, new_pc));
                break;
            }
            new_pc = null;
View Full Code Here

                        // Add to join index map which depth is the index
                        state.join_node_index.put(this.getDepth(), (AbstractJoinPlanNode) element);
                        Map<String, Integer> single_join_node_output = new HashMap<String, Integer>();
                        for (int i = 0; i < element.getOutputColumnGUIDCount(); i++) {
                            int guid = element.getOutputColumnGUID(i);
                            PlanColumn pc = state.plannerContext.get(guid);
                            single_join_node_output.put(pc.getDisplayName(), i);
                        } // FOR
                        state.join_outputs.put((AbstractJoinPlanNode) element, single_join_node_output);
                    }

                }
View Full Code Here

        final Collection<AbstractExpression> exps = PlanNodeUtil.getExpressionsForPlanNode(node);
        // If this is the root node, then include the output columns + also
        // include output columns if its a projection or limit node
        if (is_root || node instanceof ProjectionPlanNode | node instanceof LimitPlanNode) {
            for (Integer col_guid : node.getOutputColumnGUIDs()) {
                PlanColumn col = state.plannerContext.get(col_guid);
                assert (col != null) : "Invalid PlanColumn #" + col_guid;
                if (col.getExpression() != null) {
                    exps.add(col.getExpression());
                    // root_column_expressions.addAll(ExpressionUtil.getExpressions(col.getExpression(),
                    // TupleValueExpression.class));
                }
            } // FOR
        }

        // PlanNode specific extractions

        // ---------------------------------------------------
        // AGGREGATE
        // ---------------------------------------------------
        if (node instanceof AggregatePlanNode) {
            AggregatePlanNode agg_node = (AggregatePlanNode) node;
            for (Integer col_guid : agg_node.getAggregateColumnGuids()) {
                PlanColumn col = state.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 = state.plannerContext.get(col_guid);
                assert (col != null) : "Invalid PlanColumn #" + col_guid;
                if (col.getExpression() != null)
                    exps.add(col.getExpression());
            } // FOR
            // ---------------------------------------------------
            // ORDER BY
            // ---------------------------------------------------
        } else if (node instanceof OrderByPlanNode) {
            OrderByPlanNode orby_node = (OrderByPlanNode) node;
            for (Integer col_guid : orby_node.getSortColumnGuids()) {
                PlanColumn col = state.plannerContext.get(col_guid);
                assert (col != null) : "Invalid PlanColumn #" + col_guid;
                if (col.getExpression() != null)
                    exps.add(col.getExpression());
            } // FOR
        }

        if (debug.val)
            LOG.debug("Extracted " + exps.size() + " expressions from " + node);

        // Now go through our expressions and extract out the columns that are
        // referenced
        StringBuilder sb = new StringBuilder();
        for (AbstractExpression exp : exps) {
            for (Column catalog_col : ExpressionUtil.getReferencedColumns(state.catalog_db, exp)) {
                if (trace.val)
                    sb.append(String.format("\n%s => %s", node, catalog_col.fullName()));
                state.addTableColumn(catalog_col);
                state.addPlanNodeColumn(node, catalog_col);
            } // FOR
        } // FOR
        if (trace.val && sb.length() > 0)
            LOG.trace("Extracted Column References:" + sb);

        // Populate our map from Column objects to PlanColumn GUIDs
        for (Integer col_guid : node.getOutputColumnGUIDs()) {
            PlanColumn col = state.plannerContext.get(col_guid);
            assert (col != null) : "Invalid PlanColumn #" + col_guid;
            if (col.getExpression() != null) {
                Collection<Column> catalog_cols = ExpressionUtil.getReferencedColumns(state.catalog_db, col.getExpression());
                // If there is more than one column, then it's some sort of
                // compound expression
                // So we don't want to include in our mapping
                if (catalog_cols.size() == 1) {
                    state.addColumnMapping(CollectionUtil.first(catalog_cols), col_guid);
View Full Code Here

TOP

Related Classes of org.voltdb.planner.PlanColumn

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.