Package org.voltdb.catalog

Examples of org.voltdb.catalog.Database


        } // PROCEDURE
    }

    public static void clearCache(CatalogType catalog_obj) {
        assert (catalog_obj != null);
        Database catalog_db = CatalogUtil.getDatabase(catalog_obj);
        CACHE.remove(catalog_db);
    }
View Full Code Here


     *
     * @param catalog_obj
     * @return
     */
    public static Collection<Statement> getAllStatements(CatalogType catalog_obj) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_obj);
        Collection<Statement> ret = new ArrayList<Statement>();
        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            ret.addAll(catalog_proc.getStatements());
        } // FOR
        return (ret);
    }
View Full Code Here

     * @param include_sys
     * @return
     */
    public static Collection<String> getAllTableNames(CatalogType catalog_obj, boolean include_sys) {
        Set<String> tableNames = new HashSet<String>();
        Database catalog_db = CatalogUtil.getDatabase(catalog_obj);
        for (Table catalog_tbl : catalog_db.getTables()) {
            boolean is_systable = catalog_tbl.getSystable();
            if (include_sys || is_systable == false)
                tableNames.add(catalog_tbl.getName());
        } // FOR
        return (tableNames);
View Full Code Here

     * Return a mapping from Tables to their vertical partitions
     *
     * @param catalog_obj
     */
    public static Map<Table, MaterializedViewInfo> getVerticallyPartitionedTables(CatalogType catalog_obj) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_obj);
        Map<Table, MaterializedViewInfo> ret = new HashMap<Table, MaterializedViewInfo>();
        for (Table catalog_tbl : catalog_db.getTables()) {
            MaterializedViewInfo catalog_view = CatalogUtil.getVerticalPartition(catalog_tbl);
            if (catalog_view != null)
                ret.put(catalog_tbl, catalog_view);
        } // FOR
        return (ret);
View Full Code Here

    }

    public Catalog createCatalog() throws Exception {
        Catalog new_catalog = new Catalog();
        new_catalog.execute(this.catalog_db.getCatalog().serialize());
        Database new_catalog_db = new_catalog.getClusters().get(this.catalog_db.getParent().getName()).getDatabases().get(this.catalog_db.getName());

        //
        // First apply the partitioning plan to all the tables
        //
        for (Table catalog_tbl : this.plan.getTableEntries().keySet()) {
            PartitionEntry entry = this.plan.getTableEntries().get(catalog_tbl);
            Table new_catalog_tbl = new_catalog_db.getTables().get(catalog_tbl.getName());
            switch (entry.getMethod()) {
                case REPLICATION:
                    new_catalog_tbl.setIsreplicated(true);
                    break;
                case HASH:
                case MAP:
                    new_catalog_tbl.setIsreplicated(false);
                    Column new_catalog_col = new_catalog_tbl.getColumns().get(entry.getAttribute().getName());
                    new_catalog_tbl.setPartitioncolumn(new_catalog_col);
                    break;
                default:
                    LOG.fatal("Unsupported partition type '" + entry.getMethod() + "'");
                    System.exit(1);
            } // SWITCH
        } // FOR

        //
        // Then add all our of our indexes
        //
        Map<Table, Integer> table_idxs = new HashMap<Table, Integer>();
        for (Table catalog_tbl : this.indexes.keySet()) {
            for (IndexPlan.Entry index : this.indexes.get(catalog_tbl)) {
                Table new_catalog_tbl = new_catalog_db.getTables().get(catalog_tbl.getName());
                if (!table_idxs.containsKey(new_catalog_tbl)) {
                    table_idxs.put(new_catalog_tbl, 0);
                }
                int idx = table_idxs.get(new_catalog_tbl);
                table_idxs.put(new_catalog_tbl, idx + 1);
View Full Code Here

     *
     * @param catalog_obj
     * @return
     */
    public static Collection<Column> getAllColumns(CatalogType catalog_obj) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_obj);
        Set<Column> ret = new HashSet<Column>();
        for (Table catalog_tbl : catalog_db.getTables()) {
            ret.addAll(catalog_tbl.getColumns());
        } // FOR
        return (ret);
    }
View Full Code Here

     * @return
     * @throws Exception
     */
    public static Collection<Procedure> getReferencingProcedures(Table catalog_tbl) throws Exception {
        Set<Procedure> ret = new ListOrderedSet<Procedure>();
        Database catalog_db = CatalogUtil.getDatabase(catalog_tbl);
        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            if (catalog_proc.getSystemproc())
                continue;
            if (CatalogUtil.getReferencedTables(catalog_proc).contains(catalog_tbl)) {
                ret.add(catalog_proc);
            }
View Full Code Here

     * @return
     * @throws Exception
     */
    public static Collection<Procedure> getReferencingProcedures(Column catalog_col) throws Exception {
        Set<Procedure> ret = new HashSet<Procedure>();
        Database catalog_db = CatalogUtil.getDatabase(catalog_col.getParent());

        // Special Case: ReplicatedColumn
        if (catalog_col instanceof ReplicatedColumn) {
            Table catalog_tbl = catalog_col.getParent();
            for (Column col : catalog_tbl.getColumns()) {
                for (Procedure catalog_proc : catalog_db.getProcedures()) {
                    if (catalog_proc.getSystemproc())
                        continue;
                    if (CatalogUtil.getReferencedColumns(catalog_proc).contains(col)) {
                        ret.add(catalog_proc);
                    }
                } // FOR
            } // FOR
        } else {
            for (Procedure catalog_proc : catalog_db.getProcedures()) {
                if (catalog_proc.getSystemproc())
                    continue;
                if (CatalogUtil.getReferencedColumns(catalog_proc).contains(catalog_col)) {
                    ret.add(catalog_proc);
                }
View Full Code Here

     */
    public static Collection<Table> getReferencedTables(Statement catalog_stmt) {
        final CatalogUtil.Cache cache = CatalogUtil.getCatalogCache(catalog_stmt);
        Collection<Table> ret = cache.STATEMENT_TABLES.get(catalog_stmt);
        if (ret == null) {
            Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
            AbstractPlanNode node = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
            Collection<Table> tables = CatalogUtil.getReferencedTablesForTree(catalog_db, node);
            ret = Collections.unmodifiableCollection(tables);
            // cache.STATEMENT_TABLES.put(catalog_stmt, ret);
        }
View Full Code Here

    /**
     * Returns all the indexes access/modified in the given Statement's query
     * @param catalog_stmt
     */
    public static Collection<Index> getReferencedIndexes(Statement catalog_stmt) {
        Database catalog_db = CatalogUtil.getDatabase(catalog_stmt);
        AbstractPlanNode node = PlanNodeUtil.getRootPlanNodeForStatement(catalog_stmt, true);
        Collection<Index> indexes = CatalogUtil.getReferencedIndexesForTree(catalog_db, node);
        return (Collections.unmodifiableCollection(indexes));
    }
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.