Package org.voltdb.catalog

Examples of org.voltdb.catalog.Column


            // TABLE SIZE
            if (trace.val)
                LOG.trace("Estimating table size for " + catalog_tbl);
            long table_bytes = this.estimate(catalog_tbl, partitions);
            if (debug.val) {
                Column catalog_col = (catalog_tbl.getIsreplicated() ? ReplicatedColumn.get(catalog_tbl) : catalog_tbl.getPartitioncolumn());
                assert (catalog_col != null) : catalog_tbl;
                m0.put(catalog_col.fullName(), table_bytes);
            }
            bytes += table_bytes;

            // INDEXES (unsupported)
            for (Index catalog_idx : catalog_tbl.getIndexes()) {
View Full Code Here


                } // SWITCH
            }
            // NON-REPLICATED TABLE
            else {
                // We need to calculate the partition value based on this table's partitioning column
                Column catalog_col = cache_tablePartitionColumns.get(catalog_tbl);
                if (trace.val)
                    LOG.trace("Partitioning Column: " + (catalog_col != null ? catalog_col.fullName() : catalog_col));

                // MULTI-COLUMN PARTITIONING
                // Strap on your seatbelts, we're going in!!!
                if (catalog_col instanceof MultiColumn) {
                    // HACK: All multi-column look-ups on queries with an OR
                    // must be broadcast
                    if (target.isMarkedContainsOR()) {
                        if (debug.val)
                            LOG.warn("Trying to use multi-column partitioning [" + catalog_col.fullName() + "] on query that contains an 'OR': " + target);
                        table_partitions.addAll(this.all_partitions);
                    } else {
                        MultiColumn mc = (MultiColumn) catalog_col;
                        PartitionSet mc_partitions[] = this.mcPartitionSetPool.borrowObject();

                        if (trace.val)
                            LOG.trace("Calculating columns for multi-partition colunmn: " + mc);
                        boolean is_valid = true;
                        for (int i = 0, mc_cnt = mc.size(); i < mc_cnt; i++) {
                            Column mc_column = mc.get(i);
                            // assert(cache_entry.get(mc_column_key) != null) :
                            // "Null CacheEntry: " + mc_column_key;
                            if (target.predicates.containsKey(mc_column)) {
                                this.calculatePartitions(mc_partitions[i],
                                                         params,
                                                         target.is_array,
                                                         target.predicates.get(mc_column),
                                                         mc_column);
                            }

                            // Unless we have partition values for both keys,
                            // then it has to be a broadcast
                            if (mc_partitions[i].isEmpty()) {
                                if (debug.val)
                                    LOG.warn(String.format("No partitions for %s from %s. " +
                                         "Cache entry %s must be broadcast to all partitions",
                                         mc_column.fullName(), mc.fullName(), target));
                                table_partitions.addAll(this.all_partitions);
                                is_valid = false;
                                break;
                            }
                            if (trace.val)
View Full Code Here

            LOG.warn(this.stats.debug(CatalogUtil.getDatabase(catalog_tbl)));
        }
        // assert(table_stats.tuple_size_total != 0) : "Size estimate for " +
        // catalog_tbl + " is zero!";

        Column catalog_col = null;
        if (catalog_tbl.getIsreplicated()) {
            estimate += table_stats.tuple_size_total;
            if (trace.val)
                catalog_col = ReplicatedColumn.get(catalog_tbl);
        } else {
            // FIXME: Assume uniform distribution for now
            estimate += table_stats.tuple_size_total / partitions;
            if (trace.val)
                catalog_col = catalog_tbl.getPartitioncolumn();
        }
        if (trace.val)
            LOG.debug(String.format("%-30s%d [total=%d]", catalog_col.fullName() + ":", estimate, table_stats.tuple_size_total));
        return (estimate);
    }
View Full Code Here

            // necessary
            // so that we can have specific edges between vertices
            Map<Table, Set<Column>> table_column_xref0 = new HashMap<Table, Set<Column>>();
            Map<Table, Set<Column>> table_column_xref1 = new HashMap<Table, Set<Column>>();
            for (CatalogType ctype : columns0) {
                Column col = (Column) ctype;
                Table tbl = (Table) col.getParent();
                if (!table_column_xref0.containsKey(tbl)) {
                    table_column_xref0.put(tbl, new HashSet<Column>());
                }
                table_column_xref0.get(tbl).add(col);
            } // FOR
            for (CatalogType ctype : columns1) {
                Column col = (Column) ctype;
                Table tbl = (Table) col.getParent();
                if (!table_column_xref1.containsKey(tbl)) {
                    table_column_xref1.put(tbl, new HashSet<Column>());
                }
                table_column_xref1.get(tbl).add(col);
            } // FOR
View Full Code Here

            if (catalog_tbl.getSystable())
                continue;
            String table_key = CatalogKey.createKey(catalog_tbl);
            String column_key = catalogkey_map.get(table_key);
            if (column_key != null) {
                Column catalog_col = CatalogKey.getFromKey(info.catalogContext.database, column_key, Column.class);
                pplan_map.put(catalog_tbl, catalog_col);
            } else if (useCatalog) {
                pplan_map.put(catalog_tbl, catalog_tbl.getPartitioncolumn());
            }
        } // FOR
View Full Code Here

                    assert (catalog_fkey_tbl != null);

                    // Important! We only want to include tables that are
                    // actually referenced in this procedure
                    if (proc_tables.contains(catalog_fkey_tbl)) {
                        Column catalog_fkey_col = CollectionUtil.first(catalog_const.getForeignkeycols()).getColumn();
                        assert (catalog_fkey_col != null);

                        // TODO: Use real ExpressionType from the entry
                        if (!fkey_column_xrefs.containsKey(catalog_fkey_tbl)) {
                            fkey_column_xrefs.put(catalog_fkey_tbl, new PredicatePairs());
View Full Code Here

                if (pentry.getMethod() == PartitionMethodType.REPLICATION) {
                    catalog_tbl.setIsreplicated(true);
                    catalog_tbl.setPartitioncolumn(ReplicatedColumn.get(catalog_tbl));
                } else {
                    Column catalog_col = (Column) pentry.getAttribute();
                    assert (catalog_col != null);
                    if (catalog_col instanceof VerticalPartitionColumn && enableVerticalPartitions == false) {
                        catalog_col = ((VerticalPartitionColumn) catalog_col).getHorizontalColumn();
                    }
                    catalog_tbl.setPartitioncolumn(catalog_col);
View Full Code Here

                assert (e.getKey().equals(e.getValue().getParent())) : e;

            // Table Partitioning
            if (e.getKey() instanceof Table) {
                Table catalog_tbl = (Table) e.getKey();
                Column catalog_col = (Column) e.getValue();
                Column attribute = null;
                if (catalog_col instanceof ReplicatedColumn) {
                    method = PartitionMethodType.REPLICATION;
                } else {
                    method = PartitionMethodType.HASH;
                    attribute = catalog_col;
                    assert (catalog_col != null) : "Unexcept Null Partitioning Column: " + catalog_tbl.getName();
                    assert (catalog_col.getParent().equals(e.getKey())) : "Parent mismatch: " + catalog_col.getParent() + " != " + e.getKey();
                }
                TableEntry pentry = new TableEntry(method, attribute, null, null);
                try {
                    pplan.addTablePartitionEntry(catalog_tbl, pentry);
                } catch (AssertionError ex) {
                    LOG.fatal("FAILED: " + e);
                    throw ex;
                }

                // Procedure Partitioning
            } else if (e.getKey() instanceof Procedure) {
                Procedure catalog_proc = (Procedure) e.getKey();
                ProcParameter catalog_proc_param = (ProcParameter) e.getValue();
                boolean single_partition = true;
                ProcParameter attribute = null;

                if (catalog_proc.getSystemproc()) {
                    continue;
                } else if (catalog_proc_param instanceof NullProcParameter || catalog_proc_param == null || catalog_proc.getParameters().size() == 0) {
                    method = PartitionMethodType.NONE;
                    single_partition = false;
                    // attribute =
                    // NullProcParameter.getNullProcParameter(catalog_proc);
                } else {
                    method = PartitionMethodType.HASH;
                    attribute = catalog_proc_param;
                    single_partition = catalog_proc.getSinglepartition();
                    assert (catalog_proc_param != null) : "Unexcept Null ProcParameter: " + catalog_proc;
                    assert (catalog_proc_param.getParent().equals(e.getKey())) : "Parent mismatch: " + catalog_proc_param.getParent() + " != " + e.getKey();
                }
                ProcedureEntry pentry = new ProcedureEntry(method, attribute, single_partition);
                try {
                    pplan.addProcedurePartitionEntry(catalog_proc, pentry);
                } catch (AssertionError ex) {
                    LOG.fatal("FAILED: " + e);
                    throw ex;
                }

                // Unknown!
            } else {
                assert (false) : "Unexpected CatalogType: " + e.getKey();
            }
            catalog_db = CatalogUtil.getDatabase(e.getKey());
        }
        // Then go back and try to resolve foreign key relations for tables
        for (TableEntry pentry : pplan.getTableEntries().values()) {
            if (pentry.isReplicated())
                continue;
            assert (pentry != null);

            // Check whether it is partitioned on a foreign key attribute that
            // has a parent
            // who is not replicate
            Column partition_col = pentry.getAttribute();

            Column parent_col = CatalogUtil.getForeignKeyParent(partition_col);
            if (parent_col != null) {
                pentry.setMethod(PartitionMethodType.MAP);
                pentry.setParent((Table) parent_col.getParent());
                pentry.setParentAttribute(parent_col);
            }
        } // FOR
        assert (catalog_db != null);
View Full Code Here

            if (catalog_tbl.getSystable())
                continue;
            if (catalog_tbl.getIsreplicated()) {
                pplan_map.put(catalog_tbl, ReplicatedColumn.get(catalog_tbl));
            } else {
                Column partition_col = catalog_tbl.getPartitioncolumn();
                pplan_map.put(catalog_tbl, partition_col);
            }
        } // FOR
          // Procedure Partitioning
        for (Procedure catalog_proc : catalog_db.getProcedures()) {
View Full Code Here

                // ----------------------------------------------
                // TABLE PARTITIONING KEY
                // ----------------------------------------------
                if (is_table) {
                    Table current_tbl = (Table) current;
                    Column search_col = (Column) attribute;
                    Column current_col = null;

                    // Check whether this is our replication marker column
                    if (search_col instanceof ReplicatedColumn) {
                        current_tbl.setIsreplicated(true);
                        current_col = ReplicatedColumn.get(current_tbl);
                    }
                    // VerticalPartitionColumn
                    else if (search_col instanceof VerticalPartitionColumn) {
                        // We need to update the statements that can use them
                        // using the pre-compiled query plans
                        current_tbl.setIsreplicated(false);
                        current_col = search_col;
                        vp_col = (VerticalPartitionColumn) search_col;
                        assert (CatalogUtil.getDatabase(vp_col).equals(info.catalogContext.database)) : String.format("VP_COL[%d] != INFO[%d]", CatalogUtil.getDatabase(vp_col).hashCode(),
                                info.catalogContext.database.hashCode());

                        MaterializedViewInfo catalog_view = vp_col.applyUpdate();
                        assert (catalog_view != null) : "Unexpected null MaterializedViewInfo for " + current_tbl + " vertical partition:\n" + vp_col;
                        if (this.cost_model.isCachingEnabled()) {
                            if (trace.val)
                                LOG.trace("Invalidating VerticalPartition Statements in cost model: " + vp_col.getOptimizedQueries());
                            this.cost_model.invalidateCache(vp_col.getOptimizedQueries());
                        }
                        TableStatistics tstats = VerticalPartitionerUtil.computeTableStatistics(vp_col, info.stats);
                        assert (tstats != null);
                        // Add the vp's sys table to the list of tables that we
                        // need to estimate the memory
                        assert (catalog_view.getDest() != null) : "Missing parent table for " + catalog_view.fullName();
                        assert (this.current_vertical_partitions.contains(catalog_view.getDest()) == false) : vp_col;
                        this.current_vertical_partitions.add(catalog_view.getDest());
                    }
                    // MultiColumn
                    else if (search_col instanceof MultiColumn) {
                        // Nothing special?
                        current_tbl.setIsreplicated(false);
                        current_col = search_col;
                    }
                    // Otherwise partition on this particular column
                    else {
                        current_tbl.setIsreplicated(false);
                        current_col = current_tbl.getColumns().get(search_col.getName());
                    }

                    // We should always have a horizontal partition column
                    assert (current_col != null);
                    current_tbl.setPartitioncolumn(current_col);
                    assert (current_col.getName().equals(current_tbl.getPartitioncolumn().getName())) : "Unexpected " + current_col.fullName() + " != " + current_tbl.getPartitioncolumn().fullName();

                    // Estimate memory size
                    Collection<Table> tablesToEstimate = null;
                    if (hints.enable_vertical_partitioning && this.current_vertical_partitions.isEmpty() == false) {
                        tablesToEstimate = CollectionUtils.union(current_previousTables, this.current_vertical_partitions);
                    } else {
                        tablesToEstimate = current_previousTables;
                    }
                    if (trace.val)
                        LOG.trace(String.format("Calculating memory size of current solution [%s]:\n%s", current_col.fullName(), StringUtil.join("\n", current_previousTables)));
                    try {
                        memory = this.memory_estimator.estimate(info.catalogContext.database, info.getNumPartitions(), tablesToEstimate);
                    } catch (Throwable ex) {
                        throw new RuntimeException("Failed to estimate memory using new attribute " + current_col.fullName(), ex);
                    }
                    memory_exceeded = (memory > this.hints.max_memory_per_partition);
                    if (trace.val)
                        LOG.trace(String.format("%s Memory: %s [ratio=%.2f, exceeded=%s]", current_col.fullName(), StringUtil.formatSize(memory), memory / (double) hints.max_memory_per_partition,
                                memory_exceeded));
                    current_attribute = current_col;

                    // ----------------------------------------------
                    // PROCEDURE PARTITIONING PARAMETER
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.