Package org.voltdb.catalog

Examples of org.voltdb.catalog.Database


        return (createFromMap(new PartitionPlan(), pplan_map));
    }

    public static PartitionPlan createFromMap(final PartitionPlan pplan, Map<? extends CatalogType, ? extends CatalogType> pplan_map) {
        assert (pplan_map.isEmpty() == false) : "PartitionPlan map is empty!";
        Database catalog_db = null;

        for (Entry<? extends CatalogType, ? extends CatalogType> e : pplan_map.entrySet()) {
            PartitionMethodType method = null;
            if (e.getValue() != null)
                assert (e.getKey().equals(e.getValue().getParent())) : e;
View Full Code Here


     * @return
     * @throws Exception
     */
    public static Collection<VerticalPartitionColumn> generateCandidates(final Column partition_col, final WorkloadStatistics stats) throws Exception {
        final Table catalog_tbl = partition_col.getParent();
        final Database catalog_db = catalog_tbl.getParent();
        final Set<VerticalPartitionColumn> candidates = new ListOrderedSet<VerticalPartitionColumn>();

        // If the horizontal partition column is null, then there can't be any
        // vertical partition columns
        if (partition_col.getNullable()) {
View Full Code Here

         */
        protected void addTables(Collection<Table> tables) throws Exception {
            // Iterate through all of the procedures/queries and figure out
            // which
            // ones we'll actually want to look at
            Database catalog_db = (Database) CollectionUtil.first(tables).getParent();
            for (Procedure catalog_proc : catalog_db.getProcedures()) {
                for (Statement catalog_stmt : catalog_proc.getStatements()) {
                    Collection<Table> stmt_tables = CatalogUtil.getReferencedTables(catalog_stmt);
                    if (tables.containsAll(stmt_tables)) {
                        this.stmt_cache.add(CatalogKey.createKey(catalog_stmt));
                    }
View Full Code Here

    public static AbstractPlanNode compileSQL(final Procedure catalog_proc, String name, String sql) throws Exception {
        VoltCompiler compiler = new VoltCompiler();
        HSQLInterface hsql = HSQLInterface.loadHsqldb();

        Database catalog_db = (Database) catalog_proc.getParent();
        Catalog catalog = catalog_db.getCatalog();
        Statement catalog_stmt = catalog_proc.getStatements().add(name);

        StatementCompiler.compile(compiler, hsql, catalog, catalog_db, new DatabaseEstimates(), catalog_stmt, sql, true);

        // HACK: For now just return the PlanNodeList from the first fragment
View Full Code Here

        // objects
        //
        Catalog catalog = new Catalog();
        catalog.execute("add / clusters " + CatalogUtil.DEFAULT_CLUSTER_NAME);
        catalog.execute("add /clusters[" + CatalogUtil.DEFAULT_CLUSTER_NAME + "] databases " + CatalogUtil.DEFAULT_DATABASE_NAME);
        Database catalog_db = catalog.getClusters().get(CatalogUtil.DEFAULT_CLUSTER_NAME).getDatabases().get(CatalogUtil.DEFAULT_DATABASE_NAME);

        VoltCompiler compiler = new VoltCompiler();
        DDLCompiler ddl_compiler = new DDLCompiler(compiler, hzsql);
        ddl_compiler.fillCatalogFromXML(catalog, catalog_db, xmlSchema);
        return (catalog);
View Full Code Here

     * (non-Javadoc)
     * @see edu.brown.utils.JSONSerializable#toJSON(org.json.JSONStringer)
     */
    @Override
    public void toJSON(JSONStringer stringer) throws JSONException {
        Database catalog_db = CatalogUtil.getDatabase(this.catalog);

        // Procedures
        stringer.key("PROCEDURES").object();
        for (Procedure catalog_proc : catalog_db.getProcedures()) {
            if (catalog_proc.getSystemproc())
                continue;
            stringer.key(catalog_proc.getName()).object();
            for (Statement catalog_stmt : catalog_proc.getStatements()) {
                stringer.key(catalog_stmt.getName()).value(catalog_stmt.getSqltext());
            } // FOR
            stringer.endObject();
        } // FOR
        stringer.endObject();

        // Tables
        stringer.key("TABLES").object();
        for (Table catalog_tbl : catalog_db.getTables()) {
            stringer.key(catalog_tbl.getName()).object();

            stringer.key("COLUMNS").object();
            for (Column catalog_col : org.voltdb.utils.CatalogUtil.getSortedCatalogItems(catalog_tbl.getColumns(), "index")) {
                stringer.key(catalog_col.getName()).object();
View Full Code Here

    }
   
    @Override
    public void run() {
        this.finished = false;
        final Database catalog_db = CatalogUtil.getDatabase(controller.getCatalog());
        final CountDownLatch resultsToRead = controller.getResultsToReadLatch();
        final ProcessSetManager clientPSM = controller.getClientProcessSetManager();

        while (resultsToRead.getCount() > 0) {
            ProcessSetManager.OutputLine line = clientPSM.nextBlocking();
View Full Code Here

     * Return the name of the vertical partition for the given table name
     * @param tableName
     * @return
     */
    private static String getNextVerticalPartitionName(Table catalog_tbl, Collection<Column> catalog_cols) {
        Database catalog_db = ((Database)catalog_tbl.getParent());
       
        Collection<String> colNames = new HashSet<String>();
        for (Column catalog_col : catalog_cols) {
            colNames.add(catalog_col.getName());
        }
View Full Code Here

        return (addVerticalPartition(catalog_tbl, catalog_cols, createIndex));
    }
   
    public static MaterializedViewInfo addVerticalPartition(final Table catalog_tbl, final Collection<Column> catalog_cols, final boolean createIndex) throws Exception {
        assert(catalog_cols.isEmpty() == false);
        Database catalog_db = ((Database)catalog_tbl.getParent());
       
        String viewName = getNextVerticalPartitionName(catalog_tbl, catalog_cols);
        if (debug.val)
            LOG.debug(String.format("Adding Vertical Partition %s for %s: %s", viewName, catalog_tbl, catalog_cols));
       
        // Create a new virtual table
        Table virtual_tbl = catalog_db.getTables().getIgnoreCase(viewName);
        if (virtual_tbl == null) {
            virtual_tbl = catalog_db.getTables().add(viewName);
        }
        virtual_tbl.setIsreplicated(true);
        virtual_tbl.setMaterializer(catalog_tbl);
        virtual_tbl.setSystable(true);
        virtual_tbl.getColumns().clear();
View Full Code Here

    /**
     * Return an unordered set all the foreign key ancestor tables for the given table
     * @param catalog_tbl
     */
    public Collection<Table> getAncestors(Table catalog_tbl) {
        Database catalog_db = (Database) catalog_tbl.getParent();
        Set<Table> ret = new LinkedHashSet<Table>();
        String key = CatalogKey.createKey(catalog_tbl);
        for (String ancestor_key : this.table_ancestors.get(key)) {
            // If this table is missing from the catalog, then we want to stop
            // the ancestor list
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.