Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 54f7780

Browse files
committed
Fix formatting
1 parent 50a5c93 commit 54f7780

File tree

2 files changed

+51
-51
lines changed

2 files changed

+51
-51
lines changed

src/include/planner/insert_plan.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class InsertPlan : public AbstractPlan {
6767
* @param[in] insert_values Values
6868
*/
6969
InsertPlan(storage::DataTable *table,
70-
const std::vector<std::string> *columns,
70+
const std::vector<std::string> *columns,
7171
const std::vector<std::vector<std::unique_ptr<expression::AbstractExpression>>> *insert_values);
7272

7373
// Get a varlen pool - will construct the pool only if needed
@@ -199,8 +199,8 @@ class InsertPlan : public AbstractPlan {
199199
* @return true if column was found, false otherwise
200200
*/
201201
bool FindSchemaColIndex(std::string col_name,
202-
const std::vector<catalog::Column> &tbl_columns,
203-
uint32_t &index);
202+
const std::vector<catalog::Column> &tbl_columns,
203+
uint32_t &index);
204204

205205
/**
206206
* Process column specification supplied in the insert statement.
@@ -223,7 +223,7 @@ class InsertPlan : public AbstractPlan {
223223
* out the insert being a prepared statement.
224224
*/
225225
bool ProcessValueExpr(expression::AbstractExpression *expr,
226-
uint32_t schema_idx);
226+
uint32_t schema_idx);
227227

228228
/**
229229
* Set default value into a schema column

src/planner/insert_plan.cpp

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ InsertPlan::InsertPlan(storage::DataTable *table,
5555
PELOTON_ASSERT(values.size() <= schema_col_count);
5656
// uint32_t param_idx = 0;
5757
for (uint32_t column_id = 0; column_id < values.size(); column_id++) {
58-
58+
5959
auto &exp = values[column_id];
60-
auto exp_ptr = exp.get();
61-
auto ret_bool = ProcessValueExpr(exp_ptr, column_id);
62-
// there is no column specification, so we have a
63-
// direct mapping between schema cols and the value vector
64-
schema_to_insert_[column_id].in_insert_cols = true;
65-
schema_to_insert_[column_id].val_idx = column_id;
66-
if (ret_bool == true) {
67-
is_prepared_stmt = true;
68-
}
60+
auto exp_ptr = exp.get();
61+
auto ret_bool = ProcessValueExpr(exp_ptr, column_id);
62+
// there is no column specification, so we have a
63+
// direct mapping between schema cols and the value vector
64+
schema_to_insert_[column_id].in_insert_cols = true;
65+
schema_to_insert_[column_id].val_idx = column_id;
66+
if (ret_bool == true) {
67+
is_prepared_stmt = true;
68+
}
6969
}
7070
}
7171
} else {
@@ -80,41 +80,41 @@ InsertPlan::InsertPlan(storage::DataTable *table,
8080
PELOTON_ASSERT(values.size() <= schema_col_count);
8181

8282
for (uint32_t idx = 0; idx < schema_col_count; idx++) {
83-
if (schema_to_insert_[idx].in_insert_cols) {
84-
// this schema column is present in the insert columns spec.
85-
// get index into values
86-
auto val_idx = schema_to_insert_[idx].val_idx;
87-
auto &exp = values[val_idx];
88-
auto exp_ptr = exp.get();
89-
bool ret_bool = ProcessValueExpr(exp_ptr, idx);
90-
if (ret_bool) {
91-
is_prepared_stmt = true;
92-
}
93-
} else {
94-
// schema column not present in insert columns spec. Set
95-
// column to its default value
96-
SetDefaultValue(idx);
97-
}
83+
if (schema_to_insert_[idx].in_insert_cols) {
84+
// this schema column is present in the insert columns spec.
85+
// get index into values
86+
auto val_idx = schema_to_insert_[idx].val_idx;
87+
auto &exp = values[val_idx];
88+
auto exp_ptr = exp.get();
89+
bool ret_bool = ProcessValueExpr(exp_ptr, idx);
90+
if (ret_bool) {
91+
is_prepared_stmt = true;
92+
}
93+
} else {
94+
// schema column not present in insert columns spec. Set
95+
// column to its default value
96+
SetDefaultValue(idx);
97+
}
9898
}
9999

100100
if (is_prepared_stmt) {
101-
// Adjust indexes into values. When constants are present in the
102-
// value tuple spec., the value vector supplied by the prepared
103-
// statement when SetParameterValues is called, will be smaller.
104-
// It will not include any of the constants.
105-
// Adjust the mapping from schema cols -> values vector to exclude
106-
// the constant columns. If there are no constants, this is a no-op.
107-
uint32_t adjust = 0;
108-
for (uint32_t idx=0; idx < columns->size(); idx++) {
109-
uint32_t stov_idx = insert_to_schema_[idx];
110-
if (schema_to_insert_[stov_idx].set_value) {
111-
// constant, not present in PS values
112-
adjust++;
113-
} else {
114-
// adjust the index
115-
schema_to_insert_[stov_idx].val_idx -= adjust;
116-
}
117-
}
101+
// Adjust indexes into values. When constants are present in the
102+
// value tuple spec., the value vector supplied by the prepared
103+
// statement when SetParameterValues is called, will be smaller.
104+
// It will not include any of the constants.
105+
// Adjust the mapping from schema cols -> values vector to exclude
106+
// the constant columns. If there are no constants, this is a no-op.
107+
uint32_t adjust = 0;
108+
for (uint32_t idx=0; idx < columns->size(); idx++) {
109+
uint32_t stov_idx = insert_to_schema_[idx];
110+
if (schema_to_insert_[stov_idx].set_value) {
111+
// constant, not present in PS values
112+
adjust++;
113+
} else {
114+
// adjust the index
115+
schema_to_insert_[stov_idx].val_idx -= adjust;
116+
}
117+
}
118118
}
119119
}
120120
}
@@ -127,8 +127,8 @@ InsertPlan::InsertPlan(storage::DataTable *table,
127127
}
128128

129129
bool InsertPlan::FindSchemaColIndex(std::string col_name,
130-
const std::vector<catalog::Column> &tbl_columns,
131-
uint32_t &index) {
130+
const std::vector<catalog::Column> &tbl_columns,
131+
uint32_t &index) {
132132
for (auto tcol = tbl_columns.begin(); tcol != tbl_columns.end(); tcol++) {
133133
if (tcol->GetName() == col_name) {
134134
index = std::distance(tbl_columns.begin(), tcol);
@@ -152,7 +152,7 @@ void InsertPlan::ProcessColumnSpec(const std::vector<std::string> *columns) {
152152
bool found_col = FindSchemaColIndex(col_name, table_columns, idx);
153153
if (not found_col) {
154154
throw Exception("column " + col_name + " not in table " +
155-
target_table_->GetName() + " columns");
155+
target_table_->GetName() + " columns");
156156
}
157157
// we have values for this column
158158
schema_to_insert_[idx].in_insert_cols = true;
@@ -164,7 +164,7 @@ void InsertPlan::ProcessColumnSpec(const std::vector<std::string> *columns) {
164164
}
165165

166166
bool InsertPlan::ProcessValueExpr(expression::AbstractExpression *expr,
167-
uint32_t schema_idx) {
167+
uint32_t schema_idx) {
168168
auto type = schema_to_insert_[schema_idx].type;
169169

170170
if (expr == nullptr) {
@@ -183,7 +183,7 @@ bool InsertPlan::ProcessValueExpr(expression::AbstractExpression *expr,
183183
return false;
184184
} else {
185185
PELOTON_ASSERT(expr->GetExpressionType() ==
186-
ExpressionType::VALUE_PARAMETER);
186+
ExpressionType::VALUE_PARAMETER);
187187
return true;
188188
}
189189
return false;

0 commit comments

Comments
 (0)