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

Commit 71b3d2a

Browse files
committed
Run formatter again, with clang-format-3.6 installed
1 parent f8ae0ab commit 71b3d2a

File tree

2 files changed

+62
-65
lines changed

2 files changed

+62
-65
lines changed

src/include/planner/insert_plan.h

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ class InsertStatement;
2929
}
3030

3131
namespace planner {
32-
33-
class InsertPlan : public AbstractPlan {
3432

33+
class InsertPlan : public AbstractPlan {
3534
public:
3635
// Construct when SELECT comes in with it
3736
InsertPlan(storage::DataTable *table, oid_t bulk_insert_count = 1)
38-
: target_table_(table), bulk_insert_count_(bulk_insert_count) {
37+
: target_table_(table), bulk_insert_count_(bulk_insert_count) {
3938
LOG_TRACE("Creating an Insert Plan with SELECT as a child");
4039
}
4140

@@ -44,17 +43,17 @@ class InsertPlan : public AbstractPlan {
4443
InsertPlan(storage::DataTable *table,
4544
std::unique_ptr<const planner::ProjectInfo> &&project_info,
4645
oid_t bulk_insert_count = 1)
47-
: target_table_(table), project_info_(std::move(project_info)),
48-
bulk_insert_count_(bulk_insert_count) {
46+
: target_table_(table),
47+
project_info_(std::move(project_info)),
48+
bulk_insert_count_(bulk_insert_count) {
4949
LOG_TRACE("Creating an Insert Plan with a projection");
5050
}
5151

5252
// Construct with a tuple
5353
// This can only be handled by the interpreted exeuctor
54-
InsertPlan(storage::DataTable *table,
55-
std::unique_ptr<storage::Tuple> &&tuple,
54+
InsertPlan(storage::DataTable *table, std::unique_ptr<storage::Tuple> &&tuple,
5655
oid_t bulk_insert_count = 1)
57-
: target_table_(table), bulk_insert_count_(bulk_insert_count) {
56+
: target_table_(table), bulk_insert_count_(bulk_insert_count) {
5857
LOG_TRACE("Creating an Insert Plan for one tuple");
5958
tuples_.push_back(std::move(tuple));
6059
}
@@ -66,14 +65,17 @@ class InsertPlan : public AbstractPlan {
6665
* @param[in] columns Columns to insert into
6766
* @param[in] insert_values Values
6867
*/
69-
InsertPlan(storage::DataTable *table,
70-
const std::vector<std::string> *columns,
71-
const std::vector<std::vector<std::unique_ptr<expression::AbstractExpression>>> *insert_values);
68+
InsertPlan(storage::DataTable *table, const std::vector<std::string> *columns,
69+
const std::vector<
70+
std::vector<std::unique_ptr<expression::AbstractExpression>>> *
71+
insert_values);
7272

7373
// Get a varlen pool - will construct the pool only if needed
7474
type::AbstractPool *GetPlanPool();
7575

76-
PlanNodeType GetPlanNodeType() const override { return PlanNodeType::INSERT; };
76+
PlanNodeType GetPlanNodeType() const override {
77+
return PlanNodeType::INSERT;
78+
};
7779

7880
/**
7981
* @brief Save values for jdbc prepared statement insert.
@@ -83,8 +85,8 @@ class InsertPlan : public AbstractPlan {
8385
*/
8486
void SetParameterValues(std::vector<type::Value> *values) override;
8587

86-
/*
87-
* Clear the parameter values of the current insert. The plan may be
88+
/*
89+
* Clear the parameter values of the current insert. The plan may be
8890
* cached in the statement / plan cache and may be reused.
8991
*/
9092
void ClearParameterValues() override { values_.clear(); }
@@ -129,14 +131,15 @@ class InsertPlan : public AbstractPlan {
129131
return !(*this == rhs);
130132
}
131133

132-
virtual void VisitParameters(codegen::QueryParametersMap &map,
134+
virtual void VisitParameters(
135+
codegen::QueryParametersMap &map,
133136
std::vector<peloton::type::Value> &values,
134137
const std::vector<peloton::type::Value> &values_from_user) override;
135138

136139
private:
137-
/**
140+
/**
138141
* Lookup a column name in the schema columns
139-
*
142+
*
140143
* @param[in] col_name column name, from insert statement
141144
* @param[in] tbl_columns table columns from the schema
142145
* @param[out] index index into schema columns, only if found
@@ -146,7 +149,7 @@ class InsertPlan : public AbstractPlan {
146149
bool FindSchemaColIndex(std::string col_name,
147150
const std::vector<catalog::Column> &tbl_columns,
148151
uint32_t &index);
149-
152+
150153
/**
151154
* Process column specification supplied in the insert statement.
152155
* Construct a map from insert columns to schema columns. Once
@@ -170,33 +173,33 @@ class InsertPlan : public AbstractPlan {
170173
bool ProcessValueExpr(expression::AbstractExpression *expr,
171174
uint32_t schema_idx);
172175

173-
/**
176+
/**
174177
* Set default value into a schema column
175-
*
178+
*
176179
* @param[in] idx schema column index
177180
*/
178181
void SetDefaultValue(uint32_t idx);
179182

180-
private:
183+
private:
181184
// mapping from schema columns to insert columns
182185
struct SchemaColsToInsertCols {
183186
// this schema column is present in the insert columns
184187
bool in_insert_cols;
185-
188+
186189
// For a PS, insert saved value (from constant in insert values list), no
187190
// param value.
188191
bool set_value;
189-
192+
190193
// index of this column in insert columns values
191-
int val_idx;
192-
194+
int val_idx;
195+
193196
// schema column type
194197
type::TypeId type;
195-
198+
196199
// set_value refers to this saved value
197200
type::Value value;
198201
};
199-
202+
200203
// Target table
201204
storage::DataTable *target_table_ = nullptr;
202205

@@ -206,7 +209,7 @@ class InsertPlan : public AbstractPlan {
206209
// mapping from schema columns to vector of insert columns
207210
std::vector<SchemaColsToInsertCols> schema_to_insert_;
208211
// mapping from insert columns to schema columns
209-
std::vector<uint32_t> insert_to_schema_;
212+
std::vector<uint32_t> insert_to_schema_;
210213

211214
// Projection Info
212215
std::unique_ptr<const planner::ProjectInfo> project_info_;

src/planner/insert_plan.cpp

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
namespace peloton {
2222
namespace planner {
2323

24-
InsertPlan::InsertPlan(storage::DataTable *table,
25-
const std::vector<std::string> *columns,
24+
InsertPlan::InsertPlan(
25+
storage::DataTable *table, const std::vector<std::string> *columns,
2626
const std::vector<std::vector<
2727
std::unique_ptr<expression::AbstractExpression>>> *insert_values)
2828
: target_table_(table), bulk_insert_count_(insert_values->size()) {
@@ -31,8 +31,8 @@ InsertPlan::InsertPlan(storage::DataTable *table,
3131

3232
// We assume we are not processing a prepared statement insert.
3333
// Only after we have finished processing, do we know if it is a
34-
// PS or not a PS.
35-
bool is_prepared_stmt = false;
34+
// PS or not a PS.
35+
bool is_prepared_stmt = false;
3636
auto *schema = target_table_->GetSchema();
3737
auto schema_col_count = schema->GetColumnCount();
3838
insert_to_schema_.resize(columns->size());
@@ -46,7 +46,7 @@ InsertPlan::InsertPlan(storage::DataTable *table,
4646
// remember the column types
4747
schema_to_insert_[idx].type = schema->GetType(idx);
4848
}
49-
49+
5050
if (columns->empty()) {
5151
// INSERT INTO table_name VALUES (val1, val2, ...), (val1, val2, ...)
5252
for (uint32_t tuple_idx = 0; tuple_idx < insert_values->size();
@@ -55,7 +55,6 @@ 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-
5958
auto &exp = values[column_id];
6059
auto exp_ptr = exp.get();
6160
auto ret_bool = ProcessValueExpr(exp_ptr, column_id);
@@ -78,7 +77,7 @@ InsertPlan::InsertPlan(storage::DataTable *table,
7877
tuple_idx++) {
7978
auto &values = (*insert_values)[tuple_idx];
8079
PELOTON_ASSERT(values.size() <= schema_col_count);
81-
80+
8281
for (uint32_t idx = 0; idx < schema_col_count; idx++) {
8382
if (schema_to_insert_[idx].in_insert_cols) {
8483
// this schema column is present in the insert columns spec.
@@ -105,7 +104,7 @@ InsertPlan::InsertPlan(storage::DataTable *table,
105104
// Adjust the mapping from schema cols -> values vector to exclude
106105
// the constant columns. If there are no constants, this is a no-op.
107106
uint32_t adjust = 0;
108-
for (uint32_t idx=0; idx < columns->size(); idx++) {
107+
for (uint32_t idx = 0; idx < columns->size(); idx++) {
109108
uint32_t stov_idx = insert_to_schema_[idx];
110109
if (schema_to_insert_[stov_idx].set_value) {
111110
// constant, not present in PS values
@@ -126,9 +125,9 @@ InsertPlan::InsertPlan(storage::DataTable *table,
126125
}
127126
}
128127

129-
bool InsertPlan::FindSchemaColIndex(std::string col_name,
130-
const std::vector<catalog::Column> &tbl_columns,
131-
uint32_t &index) {
128+
bool InsertPlan::FindSchemaColIndex(
129+
std::string col_name, const std::vector<catalog::Column> &tbl_columns,
130+
uint32_t &index) {
132131
for (auto tcol = tbl_columns.begin(); tcol != tbl_columns.end(); tcol++) {
133132
if (tcol->GetName() == col_name) {
134133
index = std::distance(tbl_columns.begin(), tcol);
@@ -141,13 +140,13 @@ bool InsertPlan::FindSchemaColIndex(std::string col_name,
141140
void InsertPlan::ProcessColumnSpec(const std::vector<std::string> *columns) {
142141
auto *schema = target_table_->GetSchema();
143142
auto &table_columns = schema->GetColumns();
144-
auto usr_col_count = columns->size();
145-
143+
auto usr_col_count = columns->size();
144+
146145
// iterate over supplied columns
147146
for (size_t usr_col_id = 0; usr_col_id < usr_col_count; usr_col_id++) {
148-
uint32_t idx;
147+
uint32_t idx;
149148
auto col_name = columns->at(usr_col_id);
150-
149+
151150
// determine index of column in schema
152151
bool found_col = FindSchemaColIndex(col_name, table_columns, idx);
153152
if (not found_col) {
@@ -164,22 +163,21 @@ void InsertPlan::ProcessColumnSpec(const std::vector<std::string> *columns) {
164163
}
165164

166165
bool InsertPlan::ProcessValueExpr(expression::AbstractExpression *expr,
167-
uint32_t schema_idx) {
166+
uint32_t schema_idx) {
168167
auto type = schema_to_insert_[schema_idx].type;
169-
168+
170169
if (expr == nullptr) {
171170
SetDefaultValue(schema_idx);
172171
} else if (expr->GetExpressionType() == ExpressionType::VALUE_CONSTANT) {
173-
174172
auto *const_expr =
175-
dynamic_cast<expression::ConstantValueExpression *>(expr);
173+
dynamic_cast<expression::ConstantValueExpression *>(expr);
176174
type::Value value = const_expr->GetValue().CastAs(type);
177-
175+
178176
schema_to_insert_[schema_idx].set_value = true;
179177
schema_to_insert_[schema_idx].value = value;
180178
// save it, in case this is not a PS
181179
values_.push_back(value);
182-
180+
183181
return false;
184182
} else {
185183
PELOTON_ASSERT(expr->GetExpressionType() ==
@@ -190,21 +188,20 @@ bool InsertPlan::ProcessValueExpr(expression::AbstractExpression *expr,
190188
}
191189

192190
void InsertPlan::SetDefaultValue(uint32_t idx) {
193-
auto *schema = target_table_->GetSchema();
191+
auto *schema = target_table_->GetSchema();
194192
type::Value *v = schema->GetDefaultValue(idx);
195193
type::TypeId type = schema_to_insert_[idx].type;
196-
194+
197195
if (v == nullptr)
198196
// null default value
199197
values_.push_back(type::ValueFactory::GetNullValueByType(type));
200198
else
201199
// non-null default value
202200
values_.push_back(*v);
203-
}
201+
}
204202

205203
type::AbstractPool *InsertPlan::GetPlanPool() {
206-
if (pool_.get() == nullptr)
207-
pool_.reset(new type::EphemeralPool());
204+
if (pool_.get() == nullptr) pool_.reset(new type::EphemeralPool());
208205
return pool_.get();
209206
}
210207

@@ -221,7 +218,7 @@ void InsertPlan::SetParameterValues(std::vector<type::Value> *values) {
221218
// get index into values
222219
auto val_idx = schema_to_insert_[idx].val_idx;
223220
auto type = schema_to_insert_[idx].type;
224-
type::Value value = values->at(val_idx).CastAs(type);
221+
type::Value value = values->at(val_idx).CastAs(type);
225222
values_.push_back(value);
226223
} else {
227224
// not in insert cols, set default value
@@ -259,23 +256,19 @@ hash_t InsertPlan::Hash() const {
259256
}
260257

261258
bool InsertPlan::operator==(const AbstractPlan &rhs) const {
262-
if (GetPlanNodeType() != rhs.GetPlanNodeType())
263-
return false;
259+
if (GetPlanNodeType() != rhs.GetPlanNodeType()) return false;
264260

265261
auto &other = static_cast<const planner::InsertPlan &>(rhs);
266262

267263
auto *table = GetTable();
268264
auto *other_table = other.GetTable();
269265
PELOTON_ASSERT(table && other_table);
270-
if (*table != *other_table)
271-
return false;
266+
if (*table != *other_table) return false;
272267

273268
if (GetChildren().size() == 0) {
274-
if (other.GetChildren().size() != 0)
275-
return false;
269+
if (other.GetChildren().size() != 0) return false;
276270

277-
if (GetBulkInsertCount() != other.GetBulkInsertCount())
278-
return false;
271+
if (GetBulkInsertCount() != other.GetBulkInsertCount()) return false;
279272
}
280273

281274
return AbstractPlan::operator==(rhs);
@@ -291,8 +284,9 @@ void InsertPlan::VisitParameters(
291284
for (uint32_t i = 0; i < values_.size(); i++) {
292285
auto value = values_[i];
293286
auto column_id = i % columns_num;
294-
map.Insert(expression::Parameter::CreateConstParameter(value.GetTypeId(),
295-
schema->AllowNull(column_id)), nullptr);
287+
map.Insert(expression::Parameter::CreateConstParameter(
288+
value.GetTypeId(), schema->AllowNull(column_id)),
289+
nullptr);
296290
values.push_back(value);
297291
}
298292
} else {

0 commit comments

Comments
 (0)