Package org.voltdb.planner

Examples of org.voltdb.planner.PlanColumn


     */
    public static Collection<Column> getUpdatedColumnsForPlanNode(final Database catalog_db, AbstractPlanNode node) {
        Set<Column> columns = new ListOrderedSet<Column>();
        for (int ctr = 0, cnt = node.getOutputColumnGUIDs().size(); ctr < cnt; ctr++) {
            int column_guid = node.getOutputColumnGUIDs().get(ctr);
            PlanColumn column = PlannerContext.singleton().get(column_guid);
            assert (column != null);

            final String column_name = column.getDisplayName();
            String table_name = column.originTableName();

            // If there is no table name, then check whether this is a scan
            // node.
            // If it is, then we can try to get the table name from the node's
            // target
View Full Code Here


        ret += label + "[" + guids.size() + "]:\n";
        for (int ctr = 0, cnt = guids.size(); ctr < cnt; ctr++) {
            int column_guid = guids.get(ctr);
            String name = "???";
            PlanColumn column = PlannerContext.singleton().get(column_guid);
            String inner = " : guid=" + column_guid;
            if (column != null) {
                assert (column_guid == column.guid());
                name = column.getDisplayName();
                inner += " : type=" + column.type() + " : size=" + column.width() + " : sort=" + column.getSortOrder() + " : storage=" + column.getStorage();
            }

            ret += String.format("%s   [%02d] %s%s\n", spacer, ctr, name, inner);

            if (column != null && column.getExpression() != null) { // && (true
                                                                    // || node
                                                                    // instanceof
                                                                    // ProjectionPlanNode))
                                                                    // {
                ret += ExpressionUtil.debug(column.getExpression(), spacer + "    ");
            }
        } // FOR
        return (ret);
    }
View Full Code Here

            sb.append(inner_spacer).append("Truncate[" + ((DeletePlanNode) node).isTruncate() + "\n");

            // DistinctPlanNode
        } else if (node instanceof DistinctPlanNode) {
            DistinctPlanNode dist_node = (DistinctPlanNode) node;
            PlanColumn col = PlannerContext.singleton().get(dist_node.getDistinctColumnGuid());
            sb.append(inner_spacer).append("DistinctColumn[" + col + "]\n");

            // IndexScanPlanNode
        } else if (node instanceof IndexScanPlanNode) {
            IndexScanPlanNode cast_node = (IndexScanPlanNode) node;
View Full Code Here

            boolean has_weightedAvg = node.getAggregateTypes().contains(ExpressionType.AGGREGATE_WEIGHTED_AVG);
            node.getAggregateColumnGuids().clear();
            int num_cols = clone_node.getOutputColumnGUIDCount() - (has_weightedAvg ? 1 : 0);
            for (int i = 0; i < num_cols; i++) {
                Integer aggOutput = clone_node.getOutputColumnGUID(i);
                PlanColumn planCol = state.plannerContext.get(aggOutput);
                assert (planCol != null);
                AbstractExpression exp = planCol.getExpression();
                assert (exp != null);
                Collection<String> refTables = ExpressionUtil.getReferencedTableNames(exp);
                assert (refTables != null);
                if (refTables.size() == 1 && refTables.contains(PlanAssembler.AGGREGATE_TEMP_TABLE)) {
                    node.getAggregateColumnGuids().add(planCol.guid());
                }
            } // FOR
        }

        if (debug.val) {
View Full Code Here

                    exp.setValueSize(VoltType.BIGINT.getLengthInBytesForFixedTypes());
                    exp.setTableName(PlanAssembler.AGGREGATE_TEMP_TABLE);
                    exp.setColumnName("");
                    exp.setColumnAlias("_DTXN_COUNT");
                    exp.setColumnIndex(clone_agg.getOutputColumnGUIDCount());
                    PlanColumn new_pc = state.plannerContext.getPlanColumn(exp, exp.getColumnAlias());
                    clone_agg.getAggregateOutputColumns().add(clone_agg.getOutputColumnGUIDCount());
                    clone_agg.getAggregateColumnNames().add(new_pc.getDisplayName());
                    clone_agg.getOutputColumnGUIDs().add(new_pc.guid());
                }
            }
        } // FOR
       
        // Now go through the original AggregateNode (the one at the top of tree)
View Full Code Here

                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) {
                throw new RuntimeException("Failed to retrieve ORDER BY columns for " + catalog_stmt.fullName());
            }
View Full Code Here

                    // 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());
                        if (catalog_col == null) {
                            LOG.error("Invalid PlanNode:\n" + PlanNodeUtil.debug(up_node));
                        }
                        assert (catalog_col != null) : String.format("Missing %s.%s\n%s", catalog_tbl.getName(), pc.getDisplayName(), pc);

                        updateReferenceColumns(catalog_col, false, allCols, modifiedCols, readOnlyCols);
                    } // FOR
                }
                break;
View Full Code Here

            @Override
            protected void callback(final AbstractPlanNode node) {
                // We should find the Materialize node before the Insert
                if (node instanceof MaterializePlanNode) {
                    for (Integer column_guid : node.getOutputColumnGUIDs()) {
                        PlanColumn column = PlannerContext.singleton().get(column_guid);
                        assert (column != null);
                        AbstractExpression exp = column.getExpression();

                        // Now extract the CatalogType objects that are being
                        // referenced by this materialization column
                        final List<CatalogType> catalog_refs = new ArrayList<CatalogType>();
                        new ExpressionTreeWalker() {
View Full Code Here

                    // from columns to StmtParameters
                    assert (tables.size() == 1);
                    Table catalog_tbl = CollectionUtil.first(tables);
                    for (int ctr = 0, cnt = node.getOutputColumnGUIDs().size(); ctr < cnt; ctr++) {
                        int column_guid = node.getOutputColumnGUIDs().get(ctr);
                        PlanColumn column = PlannerContext.singleton().get(column_guid);
                        assert (column != null);

                        Column catalog_col = catalog_tbl.getColumns().get(column.getDisplayName());
                        assert (catalog_col != null) : "Invalid column name '" + column.getDisplayName() + "' for " + catalog_tbl;

                        AbstractExpression exp = column.getExpression();
                        if (exp instanceof ParameterValueExpression) {
                            StmtParameter catalog_param = catalog_stmt.getParameters().get(((ParameterValueExpression) exp).getParameterId());
                            cset.add(catalog_col, catalog_param, ExpressionType.COMPARE_EQUAL, catalog_stmt);
                        } else if (exp instanceof AbstractValueExpression) {
                            if (debug.val)
View Full Code Here

                List<AbstractExpression> output_exps = new ArrayList<AbstractExpression>();
                if (scan_node.getOutputColumnGUIDs().isEmpty()) {
                    if (scan_node.getInlinePlanNode(PlanNodeType.PROJECTION) != null) {
                        ProjectionPlanNode proj_node = (ProjectionPlanNode) scan_node.getInlinePlanNode(PlanNodeType.PROJECTION);
                        for (int guid : proj_node.getOutputColumnGUIDs()) {
                            PlanColumn column = PlannerContext.singleton().get(guid);
                            assert (column != null);
                            output_cols.add(column);
                            output_exps.add(column.getExpression());
                        } // FOR
                    }
                } else {
                    for (int guid : scan_node.getOutputColumnGUIDs()) {
                        PlanColumn column = PlannerContext.singleton().get(guid);
                        assert (column != null);
                        output_cols.add(column);
                        output_exps.add(column.getExpression());
                    } // FOR
                }

                for (int i = 0, cnt = output_cols.size(); i < cnt; i++) {
                    PlanColumn column = output_cols.get(i);
                    AbstractExpression exp = output_exps.get(i);
                    // Skip TupleAddressExpression
                    if (!(exp instanceof TupleAddressExpression)) {
                        //
                        // Make a temporary expression where COL = Expression
                        // Har har har! I'm so clever!
                        //
                        String column_name = (column.originColumnName() != null ? column.originColumnName() : column.getDisplayName());
                        Column catalog_col = catalog_tbl.getColumns().get(column_name);
                        if (catalog_col == null)
                            System.err.println(catalog_tbl + ": " + CatalogUtil.debug(catalog_tbl.getColumns()));
                        assert (catalog_col != null) : "Missing column '" + catalog_tbl.getName() + "." + column_name + "'";
                        AbstractExpression root_exp = CatalogUtil.createTempExpression(catalog_col, exp);
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.