Package org.voltdb.catalog

Examples of org.voltdb.catalog.Database


     * @param catalog_proc
     * @return
     */
    public static Collection<Procedure> getAllConflicts(Procedure catalog_proc) {
        List<Procedure> conflicts = new ArrayList<Procedure>();
        Database catalog_db = CatalogUtil.getDatabase(catalog_proc);
        for (ConflictSet cs : catalog_proc.getConflicts().values()) {
            if (cs.getReadwriteconflicts().isEmpty() == false) {
                conflicts.add(catalog_db.getProcedures().get(cs.getName()));
            }
            if (cs.getWritewriteconflicts().isEmpty() == false) {
                conflicts.add(catalog_db.getProcedures().get(cs.getName()));
            }
        } // FOR
        return (conflicts);
    }
View Full Code Here


     * @param catalog_proc
     * @return
     */
    public static Collection<Procedure> getReadWriteConflicts(Procedure catalog_proc) {
        List<Procedure> conflicts = new ArrayList<Procedure>();
        Database catalog_db = CatalogUtil.getDatabase(catalog_proc);
        for (ConflictSet cs : catalog_proc.getConflicts().values()) {
            if (cs.getReadwriteconflicts().isEmpty() == false) {
                conflicts.add(catalog_db.getProcedures().get(cs.getName()));
            }
        } // FOR
        return (conflicts);
    }
View Full Code Here

                } // FOR
            } // FOR
        }

        private synchronized void buildReadOnlyColumnCache(CatalogType catalog_item) {
            Database catalog_db = CatalogUtil.getDatabase(catalog_item);

            Set<Column> all_modified = new HashSet<Column>();
            Set<Column> all_modified_no_inserts = new HashSet<Column>();

            for (Procedure catalog_proc : catalog_db.getProcedures()) {
                for (Statement catalog_stmt : catalog_proc.getStatements()) {
                    QueryType qtype = QueryType.get(catalog_stmt.getQuerytype());
                    if (qtype == QueryType.SELECT)
                        continue;

                    // Get the columns that referenced by this Statement
                    CatalogUtil.getReferencedColumns(catalog_stmt);
                    Set<Column> modified_cols = STATEMENT_MODIFIED_COLUMNS.get(catalog_stmt);
                    assert (modified_cols != null) : "Failed to get modified columns for " + catalog_stmt.fullName();
                    all_modified.addAll(modified_cols);
                    if (debug.val)
                        LOG.debug("ALL - " + catalog_stmt.fullName() + ": " + modified_cols);
                    if (qtype != QueryType.INSERT) {
                        all_modified_no_inserts.addAll(modified_cols);
                        if (debug.val)
                            LOG.debug("NOINSERT - " + catalog_stmt.fullName() + ": " + modified_cols);
                    }
                } // FOR (stmt)
            } // FOR (proc)

            for (Table catalog_tbl : catalog_db.getTables()) {
                Set<Column> readonly_with_inserts = new TreeSet<Column>();
                Set<Column> readonly_no_inserts = new TreeSet<Column>();

                for (Column catalog_col : catalog_tbl.getColumns()) {
                    // If this Column was not modified at all, then we can
View Full Code Here

        } // FOR
        return;
    }

    public static void setForeignKeyConstraints(Table catalog_tbl, Map<String, String> fkeys) throws Exception {
        final Database catalog_db = (Database) catalog_tbl.getParent();

        Map<Table, Constraint> table_const_map = new HashMap<Table, Constraint>();
        for (Entry<String, String> entry : fkeys.entrySet()) {
            String column = entry.getKey();
            String fkey[] = entry.getValue().split("\\.");
            Column catalog_col = catalog_tbl.getColumns().get(column);
            Table catalog_fkey_tbl = catalog_db.getTables().get(fkey[0]);
            Column catalog_fkey_col = catalog_fkey_tbl.getColumns().get(fkey[1]);

            if (catalog_fkey_tbl == null) {
                throw new Exception("ERROR: The foreign key table for '" + fkey[0] + "." + fkey[1] + "' is null");
            } else if (catalog_fkey_col == null) {
View Full Code Here

                        assert (new_catalog_col != null);
                        new_catalog_tbl.setIsreplicated(false);
                        new_catalog_tbl.setPartitioncolumn(new_catalog_col);
                    }
                } // FOR
                Database new_catalog_db = CatalogUtil.getDatabase(new_catalog);
                CatalogCloner.cloneConstraints(info.catalogContext.database, new_catalog_db);
                CatalogContext newCatalogContext = new CatalogContext(new_catalog);

                double cost = 0d;
                try {
View Full Code Here

            if (info.mapInputQuery == null || info.mapInputQuery.isEmpty()) {
                String msg = "Procedure: " + shortName + " must include a mapInputQuery";
                throw compiler.new VoltCompilerException(msg);
            }

            Database catalog_db = CatalogUtil.getDatabase(procedure);
            VoltMapReduceProcedure<?> mrInstance = (VoltMapReduceProcedure<?>) procInstance;

            // Initialize the MapOutput table
            // Create an invocation of the VoltMapProcedure so that we can grab
            // the MapOutput's schema
            VoltTable.ColumnInfo[] schema = mrInstance.getMapOutputSchema();
            String tableMapOutput = "MAP_" + procedure.getName();
            Table catalog_tbl = catalog_db.getTables().add(tableMapOutput);
            assert (catalog_tbl != null);
            for (int i = 0; i < schema.length; i++) {
                Column catalog_col = catalog_tbl.getColumns().add(schema[i].getName());
                catalog_col.setIndex(i);
                catalog_col.setNullable(i > 0);
                catalog_col.setType(schema[i].getType().getValue());
                if (i == 0)
                    catalog_tbl.setPartitioncolumn(catalog_col);
            } // FOR
            catalog_tbl.setMapreduce(true);
            catalog_tbl.setIsreplicated(false);

            // Initialize the reduceOutput table
            VoltTable.ColumnInfo[] schema_reduceOutput = mrInstance.getReduceOutputSchema();
            String tableReduceOutput = "REDUCE_" + procedure.getName();
            catalog_tbl = catalog_db.getTables().add(tableReduceOutput);
            assert (catalog_tbl != null);
            for (int i = 0; i < schema_reduceOutput.length; i++) {
                Column catalog_col = catalog_tbl.getColumns().add(schema_reduceOutput[i].getName());
                catalog_col.setIndex(i);
                catalog_col.setNullable(i > 0);
View Full Code Here

            comparator = new CatalogFieldComparator<T>("index");
            COMPARATORS.put((Class<? extends CatalogType>) clazz, (CatalogFieldComparator<CatalogType>) comparator);
        }
        // Collections.sort(attributes, comparator);

        Database catalog_db = CatalogUtil.getDatabase(attrs[0]);
        if (!SINGLETONS.containsKey(catalog_db)) {
            SINGLETONS.put(catalog_db, new HashMap<Collection<? extends CatalogType>, MultiAttributeCatalogType<? extends CatalogType>>());
        }
        U obj = (U) SINGLETONS.get(catalog_db).get(attributes);
        if (obj == null) {
View Full Code Here

                catalog_tbl.getViews().add(this.catalog_view, false);
        }
        assert (this.catalog_view != null);

        // Make sure that the view's destination table is in the catalog
        Database catalog_db = CatalogUtil.getDatabase(catalog_view);
        if (catalog_db.getTables().contains(catalog_view.getDest()) == false) {
            if (debug.val)
                LOG.debug("Adding back " + catalog_view.getDest() + " to catalog");
            catalog_db.getTables().add(catalog_view.getDest(), false);
        } else if (debug.val) {
            LOG.debug(String.format("%s already exists in catalog %s", catalog_view.getDest(), catalog_db.getTables()));
        }

        // Apply the new Statement query plans
        if (debug.val && this.optimized.isEmpty()) {
            LOG.warn("There are no optimized query plans for " + this.fullName());
View Full Code Here

        validate(catalog_view, catalog_tbl);
    }

    private static void validate(MaterializedViewInfo catalog_view, Table catalog_tbl) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_tbl);
        assert (catalog_view.getVerticalpartition());
        assert (catalog_view.getDest() != null) : String.format("MaterializedViewInfo %s for %s is missing destination table!", catalog_view.fullName(), catalog_tbl);
        assert (catalog_db.getTables().contains(catalog_view.getDest())) : String.format("MaterializedViewInfo %s for %s is missing destination table! %s", catalog_view.fullName(), catalog_tbl,
                catalog_db.getTables());
        assert (catalog_view.getGroupbycols().isEmpty() == false) : String.format("MaterializedViewInfo %s for %s is missing groupby columns!", catalog_view.fullName(), catalog_tbl);
        assert (catalog_view.getDest().getColumns().isEmpty() == false) : String.format("MaterializedViewInfo %s for %s is missing virtual columns!", catalog_view.getDest(), catalog_tbl);
        assert (catalog_view.getParent().equals(catalog_tbl)) : String.format("MaterializedViewInfo %s has parent %s, but it should be %s!", catalog_view.fullName(), catalog_view.getParent(),
                catalog_tbl);
View Full Code Here

   
    final Map<String, String> tokenCaseSensitive = new HashMap<String, String>();
   
    public TokenCompletor(Catalog catalog) throws Exception {
        this.catalog = catalog;
        Database catalog_db = CatalogUtil.getDatabase(catalog);
       
        // Core SQL Reserved Words from HSQLDB
        for (int i = 0; i < 1000; i++) {
            if (Tokens.isCoreKeyword(i)) {
                String keyword = Tokens.getKeyword(i);
                if (keyword != null) this.sqlTokens.add(keyword);
            }
        } // FOR

        // Special command tokens
        for (QueryType qtype : QueryType.values()) {
            if (qtype == QueryType.INVALID || qtype == QueryType.NOOP) continue;
            this.commandTokens.add(qtype.name());
        } // FOR
        for (HStoreTerminal.Command c : HStoreTerminal.Command.values()) {
            this.commandTokens.add(c.name());
            this.specialTokens.add(c.name());
        } // FOR
       
        // Catalog Keywords
        // Tables, columns, procedures names
        CollectionUtil.addAll(this.tablePrefixes, TABLE_PREFIXES);
        CollectionUtil.addAll(this.columnPrefixes, COLUMN_PREFIXES);
        for (Table catalog_tbl : CatalogUtil.getDataTables(catalog_db)) {
            this.tableTokens.add(catalog_tbl.getName());
            this.columnPrefixes.add(catalog_tbl.getName() + ".");
            for (Column catalog_col : catalog_tbl.getColumns()) {
                this.columnTokens.add(catalog_col.getName().toUpperCase());
            } // FOR
        } // FOR
       
        CollectionUtil.addAll(this.procPrefixes, PROC_PREFIXES);
        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            String procName = catalog_proc.getName().toUpperCase();
            this.tokenCaseSensitive.put(procName, catalog_proc.getName());
            this.procTokens.add(procName);
        } // FOR
       
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.