Package org.voltdb.catalog

Examples of org.voltdb.catalog.Column


     * @param from_column
     * @return
     */
    public static Column getForeignKeyParent(Column from_column) {
        assert(from_column != null);
        Column to_column = null;
       
        for (Constraint catalog_const : CatalogUtil.getConstraints(from_column.getConstraints())) {
            if (catalog_const.getType() == ConstraintType.FOREIGN_KEY.getValue()) {
                assert(!catalog_const.getForeignkeycols().isEmpty());
                for (ColumnRef catalog_col_ref : catalog_const.getForeignkeycols()) {
View Full Code Here


                }
                if (!found) {
                    switch (const_type) {
                        case FOREIGN_KEY: {
                            Table catalog_fkey_tbl = catalog_const.getForeignkeytable();
                            Column catalog_fkey_col = null;
                            for (ColumnRef ref : catalog_const.getForeignkeycols()) {
                                catalog_fkey_col = ref.getColumn();
                                break; // Nasty hack to get first item
                            }

                            assert(catalog_fkey_col != null);
                            ret += " REFERENCES " + catalog_fkey_tbl.getTypeName() + " (" + catalog_fkey_col.getTypeName() + ")";
                            skip_constraints.add(catalog_const);
                            break;
                        }
                        default:
                            // Nothing for now
                    }
                }
            }

            add = ",\n";
        }

        // Constraints
        for (Constraint catalog_const : catalog_tbl.getConstraints()) {
            if (skip_constraints.contains(catalog_const)) continue;
            ConstraintType const_type = ConstraintType.get(catalog_const.getType());
            if (const_type == ConstraintType.FOREIGN_KEY && include_fkeys == false) continue;

            // Primary Keys / Unique Constraints
            if (const_type == ConstraintType.PRIMARY_KEY || const_type == ConstraintType.UNIQUE) {
                Index catalog_idx = catalog_const.getIndex();
                IndexType idx_type = IndexType.get(catalog_idx.getType());
                String idx_suffix = idx_type.getSQLSuffix();

                ret += add + spacer +
                       (!idx_suffix.isEmpty() ? "CONSTRAINT " + catalog_const.getTypeName() + " " : "") +
                       (const_type == ConstraintType.PRIMARY_KEY ? "PRIMARY KEY" : "UNIQUE") + " (";

                String col_add = "";
                for (ColumnRef catalog_colref : CatalogUtil.getSortedCatalogItems(catalog_idx.getColumns(), "index")) {
                    ret += col_add + catalog_colref.getColumn().getTypeName();
                    col_add = ", ";
                } // FOR
                ret += ")";
                skip_indexes.add(catalog_idx);

            // Foreign Key
            } else if (const_type == ConstraintType.FOREIGN_KEY) {
                Table catalog_fkey_tbl = catalog_const.getForeignkeytable();
                String col_add = "";
                String our_columns = "";
                String fkey_columns = "";
                for (ColumnRef catalog_colref : catalog_const.getForeignkeycols()) {
                    // The name of the ColumnRef is the column in our base table
                    Column our_column = catalog_tbl.getColumns().getIgnoreCase(catalog_colref.getTypeName());
                    assert(our_column != null);
                    our_columns += col_add + our_column.getTypeName();

                    Column fkey_column = catalog_colref.getColumn();
                    assert(fkey_column != null);
                    fkey_columns += col_add + fkey_column.getTypeName();

                    col_add = ", ";
                }
                ret += add + spacer + "CONSTRAINT " + catalog_const.getTypeName() + " " +
                                      "FOREIGN KEY (" + our_columns + ") " +
View Full Code Here

                LOG.fatal(CatalogUtil.debug(catalog_db.getTables()));
                throw new RuntimeException(ex);
            }
            assert (catalog_tbl != null) : "Invalid table '" + table_name + "'";

            Column catalog_col = catalog_tbl.getColumns().get(column_name);
            assert (catalog_col != null) : "Invalid column '" + table_name + "." + column_name;

            columns.add(catalog_col);
        } // FOR
        return (columns);
View Full Code Here

        MemoryEstimator estimator = new MemoryEstimator(stats, hasher);
        for (SiteEntry site : this.sites) {
            long site_size = 0l;
            for (FragmentEntry fragment : site.getFragments()) {
                Table catalog_tbl = fragment.getTable(catalog_db);
                Column partition_col = catalog_tbl.getPartitioncolumn();
                long size = estimator.estimate(catalog_tbl, partition_col, fragment.getHashKey());
                site_size += size;
                fragment.setEstimatedSize(size);
            } // FOR
            site.setEstimatedSize(site_size);
View Full Code Here

      HashMap<String, String> map = new HashMap<String, String>();
      map.put(colFullName, value);
      int endIndex = colFullName.indexOf('.');
      String tableName = colFullName.substring(0, endIndex);
      String colName = colFullName.substring(endIndex+1, colFullName.length());
      Column column = CatalogUtil.getColumn(db, tableName, colName);
      CatalogMap<ConstraintRef> constraintMap = column.getConstraints();

      if(!constraintMap.isEmpty()){
        String foreignKey = null;
        Constraint constraint = CollectionUtil.first(constraintMap).getConstraint();
        Column foreignKeyCol = CollectionUtil.first(constraint.getForeignkeycols()).getColumn();
        foreignKey = foreignKeyCol.fullName();       
        if(foreignKey!=null){
          Map<String, String> foreignKeyValueMap = new HashMap<String, String>();
          foreignKeyValueMap.put(foreignKey, value);
          ArrayList<Long> timestamps;
          if(finalResult.containsKey(foreignKeyValueMap)){
View Full Code Here

            // list of candidate columns. If it is, then that means we will want to include it the value's hash
            // when determining whether a QueryTrace is unique
            for (Statement catalog_stmt : catalog_proc.getStatements()) {
                List<StmtParameter> stmt_params = new ArrayList<StmtParameter>();
                for (StmtParameter catalog_param : catalog_stmt.getParameters()) {
                    Column catalog_col = PlanNodeUtil.getColumnForStmtParameter(catalog_param);
                    assert(catalog_col != null);
                    if (this.candidate_columns.contains(catalog_col)) {
                        stmt_params.add(catalog_param);
                    }
                } // FOR (parameter)
View Full Code Here

           
            // Gather column types
            int num_columns = voltTable.getColumnCount();
            VoltType col_types[] = new VoltType[num_columns];
            for (int i = 0; i < num_columns; i++) {
                Column catalog_col = catalog_tbl.getColumns().get(i);
                col_types[i] = VoltType.get((byte)catalog_col.getType());
            } // FOR

            loader_query.params = new Object[num_columns];
            int num_tuples = voltTable.getRowCount();
            try {
View Full Code Here

        // referenced in this procedure
        Map<ProcParameter, List<Double>> param_weights = new HashMap<ProcParameter, List<Double>>();
        for (Table catalog_tbl : info.catalogContext.database.getTables()) {
            if (catalog_tbl.getIsreplicated())
                continue;
            Column catalog_col = catalog_tbl.getPartitioncolumn();
            if (!col_access_histogram.contains(catalog_col))
                continue;
            long col_access_cnt = col_access_histogram.get(catalog_col);

            if (debug.val)
View Full Code Here

        // Get the list of tables accessed by this procedure
        for (Table catalog_tbl : CatalogUtil.getReferencedTables(catalog_proc)) {
            if (catalog_tbl.getIsreplicated())
                continue;
            Column catalog_col = catalog_tbl.getPartitioncolumn();

            for (ProcParameter catalog_proc_param : catalog_proc.getParameters()) {
                // Skip if this is an array
                if (hints.enable_array_procparameter_candidates == false && catalog_proc_param.getIsarray())
                    continue;
View Full Code Here

        // descendants they have
        DependencyUtil dependencies = DependencyUtil.singleton(CatalogUtil.getDatabase(catalog_tbl));
        if (debug.val)
            LOG.debug("Calculating descendants for columns");
        for (Entry<Column, Double> entry : column_weights.entrySet()) {
            Column catalog_col = entry.getKey();
            Double weight = entry.getValue();
            int descendants = dependencies.getDescendants(catalog_col).size();
            column_weights.put(catalog_col, weight * (descendants + 1));
            if (descendants > 0)
                LOG.debug("  " + catalog_col + ": " + descendants);
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Column

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.