void UMaterialInstanceDynamic::CopyParameterOverrides(UMaterialInstance* MaterialInstance) { ClearParameterValues(); VectorParameterValues = MaterialInstance->VectorParameterValues; ScalarParameterValues = MaterialInstance->ScalarParameterValues; TextureParameterValues = MaterialInstance->TextureParameterValues; FontParameterValues = MaterialInstance->FontParameterValues; InitResources(); }
InsertPlan::InsertPlan( storage::DataTable *table, const std::vector<std::string> *columns, const std::vector<std::vector< std::unique_ptr<expression::AbstractExpression>>> *insert_values) : target_table_(table), bulk_insert_count_(insert_values->size()) { LOG_TRACE("Creating an Insert Plan with multiple expressions"); PELOTON_ASSERT(target_table_); // We assume we are not processing a prepared statement insert. // Only after we have finished processing, do we know if it is a // PS or not a PS. bool is_prepared_stmt = false; auto *schema = target_table_->GetSchema(); auto schema_col_count = schema->GetColumnCount(); insert_to_schema_.resize(columns->size()); // initialize mapping from schema cols to insert values vector. // will be updated later based on insert columns and values schema_to_insert_.resize(schema_col_count); for (uint32_t idx = 0; idx < schema_col_count; idx++) { schema_to_insert_[idx].in_insert_cols = false; schema_to_insert_[idx].set_value = false; schema_to_insert_[idx].val_idx = 0; // remember the column types schema_to_insert_[idx].type = schema->GetType(idx); } if (columns->empty()) { // INSERT INTO table_name VALUES (val1, val2, ...), (val1, val2, ...) for (uint32_t tuple_idx = 0; tuple_idx < insert_values->size(); tuple_idx++) { auto &values = (*insert_values)[tuple_idx]; PELOTON_ASSERT(values.size() <= schema_col_count); // uint32_t param_idx = 0; for (uint32_t column_id = 0; column_id < values.size(); column_id++) { auto &exp = values[column_id]; auto exp_ptr = exp.get(); auto ret_bool = ProcessValueExpr(exp_ptr, column_id); // there is no column specification, so we have a // direct mapping between schema cols and the value vector schema_to_insert_[column_id].in_insert_cols = true; schema_to_insert_[column_id].val_idx = column_id; if (ret_bool == true) { is_prepared_stmt = true; } } // for remaining columns, insert defaults for (uint32_t column_id = values.size(); column_id != schema_col_count; ++column_id) { SetDefaultValue(column_id); } } } else { // INSERT INTO table_name (col1, col2, ...) VALUES (val1, val2, ...); // Columns may be in any order. Values may include constants. PELOTON_ASSERT(columns->size() <= schema_col_count); // construct the mapping between schema cols and insert cols ProcessColumnSpec(columns); for (uint32_t tuple_idx = 0; tuple_idx < insert_values->size(); tuple_idx++) { auto &values = (*insert_values)[tuple_idx]; PELOTON_ASSERT(values.size() <= schema_col_count); for (uint32_t idx = 0; idx < schema_col_count; idx++) { if (schema_to_insert_[idx].in_insert_cols) { // this schema column is present in the insert columns spec. // get index into values auto val_idx = schema_to_insert_[idx].val_idx; auto &exp = values[val_idx]; auto exp_ptr = exp.get(); bool ret_bool = ProcessValueExpr(exp_ptr, idx); if (ret_bool) { is_prepared_stmt = true; } } else { // schema column not present in insert columns spec. Set // column to its default value SetDefaultValue(idx); } } if (is_prepared_stmt) { // Adjust indexes into values. When constants are present in the // value tuple spec., the value vector supplied by the prepared // statement when SetParameterValues is called, will be smaller. // It will not include any of the constants. // Adjust the mapping from schema cols -> values vector to exclude // the constant columns. If there are no constants, this is a no-op. uint32_t adjust = 0; for (uint32_t idx = 0; idx < columns->size(); idx++) { uint32_t stov_idx = insert_to_schema_[idx]; if (schema_to_insert_[stov_idx].set_value) { // constant, not present in PS values adjust++; } else { // adjust the index schema_to_insert_[stov_idx].val_idx -= adjust; } } } } } if (is_prepared_stmt) { // We've been assuming it is not a PS and saving into the values_ // vector. Now that we know it is a PS, we must clear those values // so SetParameterValues will operate correctly. ClearParameterValues(); } }