Package org.voltdb.catalog

Examples of org.voltdb.catalog.Database


    /**
     * Get all the tables referenced in this PlanFragment
     * @param catalog_fag
     */
    public static Collection<Table> getReferencedTables(PlanFragment catalog_frag) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_frag);
        AbstractPlanNode node = PlanNodeUtil.getPlanNodeTreeForPlanFragment(catalog_frag);
        return (CatalogUtil.getReferencedTablesForTree(catalog_db, node));
    }
View Full Code Here


        this.catalog = catalog;
       
        // Procedures to exclude in Conflict Graph
        if (args.hasParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES)) {
            String param = args.getParam(ArgumentsParser.PARAM_CONFLICTS_EXCLUDE_PROCEDURES);
            Database catalog_db = CatalogUtil.getDatabase(this.catalog);
            for (String procName : param.split(",")) {
                Procedure catalog_proc = catalog_db.getProcedures().getIgnoreCase(procName);
                if (catalog_proc != null) {
                    this.conflictGraphExcludes.add(catalog_proc);
                } else {
                    LOG.warn("Invalid procedure name to exclude '" + procName + "'");
                }
View Full Code Here

            LOG.debug("Extracting referenced columns from statement " + CatalogUtil.getDisplayName(catalog_stmt));

        final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_stmt);
        Set<Column> ret = cache.STATEMENT_ALL_COLUMNS.get(catalog_stmt);
        if (ret == null) {
            final Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
            ret = new ListOrderedSet<Column>();

            CatalogFieldComparator<Column> comparator = new CatalogFieldComparator<Column>("index");
            Set<Column> modified = new TreeSet<Column>(comparator);
            Set<Column> readOnly = new TreeSet<Column>(comparator);
View Full Code Here

           
                // Conflicts
                if (catalog_proc.getConflicts().isEmpty() == false) {
                    DefaultMutableTreeNode conflictRootNode = new CatalogMapTreeNode(ConflictSet.class, "Conflicts", catalog_proc.getConflicts());
                    procNode.add(conflictRootNode);
                    Database catalog_db = CatalogUtil.getDatabase(catalog_proc);
                   
                    for (ConflictSet conflicts : catalog_proc.getConflicts()) {
                        final Procedure other = catalog_db.getProcedures().getIgnoreCase(conflicts.getName());
                        assert(other != null) : "Invalid conflict procedure name '" + conflicts.getName() + "'";
                        String attrText = "";
                       
                        // READ-WRITE CONFLICTS
                        attrText += this.formatConflictSet(conflicts.getReadwriteconflicts().values(), ConflictType.READ_WRITE);
View Full Code Here

            LOG.debug("Extracting order-by columns from statement " + CatalogUtil.getDisplayName(catalog_stmt));

        final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_stmt);
        Set<Column> ret = cache.STATEMENT_ORDERBY_COLUMNS.get(catalog_stmt);
        if (ret == null) {
            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();
View Full Code Here

     * @param convert_params
     * @return
     * @throws Exception
     */
    public static PredicatePairs extractStatementPredicates(final Statement catalog_stmt, final boolean convert_params) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
        Table tables[] = catalog_db.getTables().values();
        return (CatalogUtil.extractStatementPredicates(catalog_stmt, convert_params, tables));
    }
View Full Code Here

     * @throws Exception
     */
    public static PredicatePairs extractStatementPredicates(final Statement catalog_stmt,
                                                            final boolean convert_params,
                                                            final Table... catalog_tables) {
        final Database catalog_db = (Database) catalog_stmt.getParent().getParent();
        final Set<Table> tables = new HashSet<Table>();
        final Collection<String> table_keys = new HashSet<String>();
        for (Table table : catalog_tables) {
            // For some reason we get a null table when we use itemsArray up above
            if (table == null)
View Full Code Here

     */
    public static PredicatePairs extractUpdateColumnSet(final Statement catalog_stmt,
                                                   final boolean convert_params,
                                                   final Table... catalog_tables) throws Exception {
        assert (catalog_stmt.getQuerytype() == QueryType.UPDATE.getValue());
        final Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);

        final Set<Table> tables = new HashSet<Table>();
        final Collection<String> table_keys = new HashSet<String>();
        for (Table table : catalog_tables) {
            tables.add(table);
View Full Code Here

     */
    public static PredicatePairs extractFragmentPredicates(final PlanFragment catalog_frag,
                                                     final boolean convert_params,
                                                     final Collection<Table> catalog_tables) throws Exception {
        final Statement catalog_stmt = (Statement) catalog_frag.getParent();
        final Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
        // if (catalog_frag.guid == 279) LOG.setLevel(Level.DEBUG);

        // We need to be clever about what we're doing here
        // We always have to examine the fragment (rather than just the entire
        // Statement), because
View Full Code Here

                                               final PredicatePairs cset,
                                               final AbstractPlanNode root_node,
                                               final boolean convert_params,
                                               final Table... catalog_tables) throws Exception {
        assert (catalog_stmt.getQuerytype() == QueryType.INSERT.getValue());
        final Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
        final List<List<CatalogType>> materialize_elements = new ArrayList<List<CatalogType>>();

        // Find the MaterializePlanNode that feeds into the Insert
        // This will have the list of columns that will be used to insert into
        // the table
        new PlanNodeTreeWalker() {
            @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() {
                            @Override
                            protected void callback(AbstractExpression exp) {
                                if (!(exp instanceof AbstractValueExpression))
                                    return;
                                CatalogType element = null;
                                switch (exp.getExpressionType()) {
                                    case VALUE_PARAMETER: {
                                        int param_idx = ((ParameterValueExpression) exp).getParameterId();
                                        element = catalog_stmt.getParameters().get(param_idx);
                                        if (element == null) {
                                            LOG.warn("ERROR: Unable to find Parameter object in catalog [" + ((ParameterValueExpression) exp).getParameterId() + "]");
                                            this.stop();
                                        }
                                        // We want to use the ProcParameter instead of the StmtParameter
                                        // It's not an error if the StmtParameter is not mapped to a
                                        // ProcParameter
                                        if (convert_params && ((StmtParameter) element).getProcparameter() != null) {
                                            LOG.debug(element + "(" + element + ") --> ProcParameter[" + element.getField("procparameter") + "]");
                                            element = ((StmtParameter) element).getProcparameter();
                                        }
                                        break;
                                    }
                                    case VALUE_TUPLE_ADDRESS:
                                    case VALUE_TUPLE: {
                                        // This shouldn't happen, but it is nice
                                        // to be told if it does...
                                        LOG.warn("Unexpected " + exp.getClass().getSimpleName() + " node when examining " + node.getClass().getSimpleName() + " for " + catalog_stmt);
                                        break;
                                    }
                                    default: {
                                        // Do nothing...
                                    }
                                } // SWITCH
                                if (element != null) {
                                    catalog_refs.add(element);
                                    LOG.debug(node + ": " + catalog_refs);
                                }
                                return;
                            }
                        }.traverse(exp);
                        materialize_elements.add(catalog_refs);
                    } // FOR

                    // InsertPlanNode
                } else if (node instanceof InsertPlanNode) {
                    InsertPlanNode insert_node = (InsertPlanNode) node;
                    Table catalog_tbl = catalog_db.getTables().get(insert_node.getTargetTableName());

                    // We only support when the Materialize node is inserting
                    // data into all columns
                    if (materialize_elements.size() != catalog_tbl.getColumns().size()) {
                        String msg = String.format("%s has %d columns but the MaterializePlanNode has %d output columns", catalog_tbl, catalog_tbl.getColumns().size(), materialize_elements.size());
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Database

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.