Package org.voltdb.catalog

Examples of org.voltdb.catalog.Table


        // Go through each table referenced in this CacheEntry and look-up the parameters that the
        // partitioning columns are referenced against to determine what partitions we need to go to
        // IMPORTANT: If there are no tables (meaning it's some PlanFragment that combines data output
        // from other PlanFragments), then won't return anything because it is up to whoever
        // to figure out where to send this PlanFragment (it may be at the coordinator)
        Table tables[] = target.getTables();
        if (trace.val) {
            Map<String, Object> m = new LinkedHashMap<String, Object>();
            m.put("CacheEntry", target.toString());
            m.put("Tables", tables);
            m.put("Params", Arrays.toString(params));
            m.put("Base Partition", base_partition);
            LOG.trace("Calculating partitions for " + target.query_type + "\n" + StringUtil.formatMaps(m));
        }
        for (int table_idx = 0; table_idx < target.is_replicated.length; table_idx++) {
            final Table catalog_tbl = tables[table_idx];

            // REPLICATED TABLE
            if (target.is_replicated[table_idx]) {
                switch (stmt_type) {
                    // If this table is replicated and this query is a scan,
View Full Code Here


            // 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);
                catalog_col.setType(schema_reduceOutput[i].getType().getValue());
                if (i == 0)
                    catalog_tbl.setPartitioncolumn(catalog_col);
            } // FOR
            catalog_tbl.setMapreduce(true);
            catalog_tbl.setIsreplicated(false);

            // Initialize the Procedure catalog object
            procedure.setMapinputquery(info.mapInputQuery);
            procedure.setMapemittable(tableMapOutput);
            procedure.setReduceemittable(tableReduceOutput);
View Full Code Here

        // and we have the same number of PlanColumns as that table has in the
        // catalog
        // This means that we don't need the projection because they're doing a
        // SELECT *
        if (new_output_tables.size() == 1) {
            Table catalog_tbl = CollectionUtil.first(new_output_tables);
            assert (catalog_tbl != null);
            // Only create the projection if the number of columns we need to
            // output is less then the total number of columns for the table
            if (new_output_cols.size() == catalog_tbl.getColumns().size()) {
                if (debug.val)
                    LOG.debug("SKIP - All columns needed in query. No need for inline projection on " + catalog_tbl);
                return (false);
            }
        }
View Full Code Here

         * @param catalog_db
         * @param parent_table_name
         * @param scale_factor
         */
        public void addAdditionDependency(Database catalog_db, String parent_table_name, double scale_factor) {
            Table parent_tbl = catalog_db.getTables().get(parent_table_name);
            assert (!this.catalog_tbl.equals(parent_tbl)) : "Trying to make table " + this.catalog_tbl + " depend on itself";
            this.dependencies.add(new DependencyOperation(parent_tbl, ExpressionType.OPERATOR_PLUS, scale_factor));
        }
View Full Code Here

         * @param catalog_db
         * @param parent_table_name
         * @param scale_factor
         */
        public void addMultiplicativeDependency(Database catalog_db, String parent_table_name, double scale_factor) {
            Table parent_tbl = catalog_db.getTables().get(parent_table_name);
            assert (!this.catalog_tbl.equals(parent_tbl)) : "Trying to make table " + this.catalog_tbl + " depend on itself";
            this.dependencies.add(new DependencyOperation(parent_tbl, ExpressionType.OPERATOR_MULTIPLY, scale_factor));
        }
View Full Code Here

       
        // Keep track of table stats
        if (m_tableStats && cr.getStatus() == Status.OK) {
            final CatalogContext catalogContext = this.getCatalogContext();
            assert(catalogContext != null);
            final Table catalog_tbl = catalogContext.getTableByName(tableName);
            assert(catalog_tbl != null) : "Invalid table name '" + tableName + "'";
           
            synchronized (m_tableStatsData) {
                TableStatistics stats = m_tableStatsData.get(catalog_tbl);
                if (stats == null) {
View Full Code Here

    public boolean isUpdateApplied() {
        return (this.applied);
    }

    public synchronized MaterializedViewInfo createMaterializedView() {
        Table catalog_tbl = this.getParent();
        MaterializedViewInfo catalog_view = CatalogUtil.getVerticalPartition(catalog_tbl);
        if (catalog_view == null || catalog_view.getDest() == null) {
            Collection<Column> cols = this.getVerticalPartitionColumns();
            assert (cols.size() > 0) : "No Vertical Partition columns for " + this;
            if (trace.val)
                LOG.trace("Creating VerticalPartition in catalog for " + catalog_tbl + ": " + cols);
            try {
                catalog_view = VoltCompiler.addVerticalPartition(catalog_tbl, cols, true);
                assert (catalog_view != null);
            } catch (Throwable ex) {
                throw new RuntimeException("Failed to create vertical partition for " + this, ex);
            }
            if (debug.val)
                LOG.debug(String.format("Created vertical partition %s.%s: %s", catalog_tbl.getName(), catalog_view.getName(), CatalogUtil.debug(catalog_view.getDest().getColumns())));

        } else if (debug.val) {
            LOG.debug(String.format("Using existing vertical partition %s.%s: %s", catalog_tbl.getName(), catalog_view.getName(), CatalogUtil.debug(catalog_view.getDest().getColumns())));
        }
        validate(catalog_view, catalog_tbl);
        return (catalog_view);
    }
View Full Code Here

     * Create the MaterializedView catalog object for this vertical partition
     * candidate
     */
    public MaterializedViewInfo applyUpdate() {
        assert (this.applied == false) : "Trying to apply " + this + " more than once";
        Table catalog_tbl = this.getParent();
        assert (catalog_tbl != null);

        if (this.catalog_view == null) {
            this.catalog_view = this.createMaterializedView();
        } else {
            if (debug.val)
                LOG.debug("Reusing existing vertical partition " + this.catalog_view + " for " + catalog_tbl);
            if (catalog_tbl.getViews().contains(catalog_view) == false)
                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);
View Full Code Here

     */
    public void revertUpdate() {
        assert (this.catalog_view != null);
        assert (this.applied) : "Trying to undo " + this + " before applying";

        Table catalog_tbl = this.getParent();
        assert (catalog_tbl != null);
        if (debug.val)
            LOG.debug(String.format("Reverting catalog update on %s for %s", catalog_tbl, this.catalog_view));
        assert (catalog_tbl.getViews().contains(this.catalog_view));
        catalog_tbl.getViews().remove(this.catalog_view);

        // Restore the original query plans from the backups
        for (Statement catalog_stmt : this.optimized.keySet()) {
            Statement backup = this.backups.get(catalog_stmt);
            assert (backup != null) : "Missing backup for " + catalog_stmt.fullName();
View Full Code Here

   
    public String getSelectedTable() {
        int idx = this.tableListTable.getSelectedRow();
        String table_key = null;
        if (idx != -1) {
            Table catalog_tbl = this.tableModel.getTables().get(idx);
            assert(catalog_tbl != null);
            table_key = CatalogKey.createKey(catalog_tbl);
        }
        return (table_key);
    }
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Table

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.