}
// Keep track of whether we have a VerticalPartitionColumn that
// needs to be
// reset after each round
VerticalPartitionColumn vp_col = null;
// Get our workload filter for this level of the traversal
Filter filter = BranchAndBoundPartitioner.this.traversal_filters.get(current);
// Descendant tables used for memory calculations
// It's ok for it to be empty. That means we're searching against
// all of tables
Set<Table> current_previousTables = this.previous_tables[idx];
assert (current_previousTables != null) : String.format("No previous tables at index %d? [current=%s, num_tables=%d]", idx, current, num_tables);
// The local best vertex is the best vertex for this level in the
// traversal
StateVertex local_best_vertex = null;
// Just make sure that if we have a VerticalPartitionColumn in our
// list of
// current attributes that it's optimizations are not applied
// If they are, then we can disable them
for (CatalogType attribute : current_attributes) {
if (attribute instanceof VerticalPartitionColumn && ((VerticalPartitionColumn) attribute).isUpdateApplied()) {
((VerticalPartitionColumn) attribute).revertUpdate();
}
} // FOR
// Iterate through the columns and find the one with the best cost
int attribute_ctr = 0;
for (CatalogType attribute : current_attributes) {
assert (attribute != null) : "Null attribute key for " + current + ": " + current_attributes;
String attribute_key = CatalogKey.createKey(attribute);
if (trace.val)
LOG.trace("Evaluating " + attribute.fullName());
boolean memory_exceeded = false;
Long memory = null;
CatalogType current_attribute = null;
// Is this the last element we have to look at
boolean last_attribute = (++attribute_ctr == num_attributes);
// Dynamic Debugging
this.cost_model.setDebuggingEnabled(this.hints.isDebuggingEnabled(attribute_key));
// IMPORTANT: We have to invalidate the cache for the current
// element *AND* all those levels
// below us in the search tree!
if (this.cost_model.isCachingEnabled()) {
for (int i = idx; i < this.num_elements; i++) {
if (trace.val)
LOG.trace("Invalidating " + this.all_search_keys.get(i));
this.cost_model.invalidateCache(this.all_search_keys.get(i));
} // FOR
// If we're not using caching, then just clear out the cost
// model completely
} else {
this.cost_model.clear();
}
// ----------------------------------------------
// 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