Skip to content

Commit

Permalink
fix compile bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hnwyllmm committed Nov 19, 2024
1 parent 4f79f4f commit 0936d27
Show file tree
Hide file tree
Showing 28 changed files with 77 additions and 87 deletions.
2 changes: 1 addition & 1 deletion src/common/lang/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ See the Mulan PSL v2 for more details. */

using std::max;
using std::min;
using std::transform;
using std::swap;
using std::transform;
4 changes: 2 additions & 2 deletions src/common/lang/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ See the Mulan PSL v2 for more details. */
#include "common/lang/sstream.h"
#include "common/lang/set.h"

using std::stof;
using std::stol;
using std::string;
using std::to_string;
using std::stol;
using std::stof;

namespace common {

Expand Down
8 changes: 4 additions & 4 deletions src/observer/sql/executor/sql_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ class SqlResult
bool has_operator() const { return operator_ != nullptr; }
const TupleSchema &tuple_schema() const { return tuple_schema_; }
RC return_code() const { return return_code_; }
const string &state_string() const { return state_string_; }
const string &state_string() const { return state_string_; }

RC open();
RC close();
RC next_tuple(Tuple *&tuple);
RC next_chunk(Chunk &chunk);

private:
Session *session_ = nullptr; ///< 当前所属会话
Session *session_ = nullptr; ///< 当前所属会话
unique_ptr<PhysicalOperator> operator_; ///< 执行计划
TupleSchema tuple_schema_; ///< 返回的表头信息。可能有也可能没有
RC return_code_ = RC::SUCCESS;
TupleSchema tuple_schema_; ///< 返回的表头信息。可能有也可能没有
RC return_code_ = RC::SUCCESS;
string state_string_;
};
8 changes: 4 additions & 4 deletions src/observer/sql/expr/aggregate_hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class StandardAggregateHashTable : public AggregateHashTable

private:
/// group by values -> aggregate values
StandardHashTable aggr_values_;
StandardHashTable aggr_values_;
vector<AggregateExpr::Type> aggr_types_;
};

Expand Down Expand Up @@ -162,10 +162,10 @@ class LinearProbingAggregateHashTable : public AggregateHashTable
static const int EMPTY_KEY;
static const int DEFAULT_CAPACITY;

vector<int> keys_;
vector<V> values_;
vector<int> keys_;
vector<V> values_;
int size_ = 0;
int capacity_ = 0;
AggregateExpr::Type aggregate_type_;
};
#endif // USE_SIMD
#endif // USE_SIMD
10 changes: 5 additions & 5 deletions src/observer/sql/expr/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class CastExpr : public Expression

private:
unique_ptr<Expression> child_; ///< 从这个表达式转换
AttrType cast_type_; ///< 想要转换成这个类型
AttrType cast_type_; ///< 想要转换成这个类型
};

/**
Expand Down Expand Up @@ -309,7 +309,7 @@ class ComparisonExpr : public Expression
RC compare_column(const Column &left, const Column &right, vector<uint8_t> &result) const;

private:
CompOp comp_;
CompOp comp_;
unique_ptr<Expression> left_;
unique_ptr<Expression> right_;
};
Expand Down Expand Up @@ -342,7 +342,7 @@ class ConjunctionExpr : public Expression
vector<unique_ptr<Expression>> &children() { return children_; }

private:
Type conjunction_type_;
Type conjunction_type_;
vector<unique_ptr<Expression>> children_;
};

Expand Down Expand Up @@ -399,7 +399,7 @@ class ArithmeticExpr : public Expression
RC execute_calc(const Column &left, const Column &right, Column &result, Type type, AttrType attr_type) const;

private:
Type arithmetic_type_;
Type arithmetic_type_;
unique_ptr<Expression> left_;
unique_ptr<Expression> right_;
};
Expand Down Expand Up @@ -464,6 +464,6 @@ class AggregateExpr : public Expression
static RC type_from_string(const char *type_str, Type &type);

private:
Type aggregate_type_;
Type aggregate_type_;
unique_ptr<Expression> child_;
};
2 changes: 1 addition & 1 deletion src/observer/sql/expr/expression_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ class ExpressionTuple : public Tuple

private:
const vector<ExprPointerType> &expressions_;
const Tuple *child_tuple_ = nullptr;
const Tuple *child_tuple_ = nullptr;
};
15 changes: 6 additions & 9 deletions src/observer/sql/expr/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class Tuple

virtual string to_string() const
{
string str;
const int cell_num = this->cell_num();
string str;
const int cell_num = this->cell_num();
for (int i = 0; i < cell_num - 1; i++) {
Value cell;
cell_at(i, cell);
Expand Down Expand Up @@ -242,8 +242,8 @@ class RowTuple : public Tuple
const Record &record() const { return *record_; }

private:
Record *record_ = nullptr;
const Table *table_ = nullptr;
Record *record_ = nullptr;
const Table *table_ = nullptr;
vector<FieldExpr *> speces_;
};

Expand All @@ -259,10 +259,7 @@ class ProjectTuple : public Tuple
ProjectTuple() = default;
virtual ~ProjectTuple() = default;

void set_expressions(vector<unique_ptr<Expression>> &&expressions)
{
expressions_ = std::move(expressions);
}
void set_expressions(vector<unique_ptr<Expression>> &&expressions) { expressions_ = std::move(expressions); }

auto get_expressions() const -> const vector<unique_ptr<Expression>> & { return expressions_; }

Expand Down Expand Up @@ -303,7 +300,7 @@ class ProjectTuple : public Tuple
#endif
private:
vector<unique_ptr<Expression>> expressions_;
Tuple *tuple_ = nullptr;
Tuple *tuple_ = nullptr;
};

/**
Expand Down
6 changes: 3 additions & 3 deletions src/observer/sql/operator/aggregate_vec_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AggregateVecPhysicalOperator : public PhysicalOperator
};
vector<Expression *> aggregate_expressions_; /// 聚合表达式
vector<Expression *> value_expressions_;
Chunk chunk_;
Chunk output_chunk_;
AggregateValues aggr_values_;
Chunk chunk_;
Chunk output_chunk_;
AggregateValues aggr_values_;
};
6 changes: 3 additions & 3 deletions src/observer/sql/operator/calc_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CalcPhysicalOperator : public PhysicalOperator
}

private:
vector<unique_ptr<Expression>> expressions_;
ExpressionTuple<unique_ptr<Expression>> tuple_;
bool emitted_ = false;
vector<unique_ptr<Expression>> expressions_;
ExpressionTuple<unique_ptr<Expression>> tuple_;
bool emitted_ = false;
};
2 changes: 1 addition & 1 deletion src/observer/sql/operator/explain_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ class ExplainPhysicalOperator : public PhysicalOperator
void generate_physical_plan();

private:
string physical_plan_;
string physical_plan_;
ValueListTuple tuple_;
};
4 changes: 2 additions & 2 deletions src/observer/sql/operator/expr_vec_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ class ExprVecPhysicalOperator : public PhysicalOperator

private:
vector<Expression *> expressions_; /// 表达式
Chunk chunk_;
Chunk evaled_chunk_;
Chunk chunk_;
Chunk evaled_chunk_;
};
5 changes: 2 additions & 3 deletions src/observer/sql/operator/hash_group_by_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ See the Mulan PSL v2 for more details. */
class HashGroupByPhysicalOperator : public GroupByPhysicalOperator
{
public:
HashGroupByPhysicalOperator(
vector<unique_ptr<Expression>> &&group_by_exprs, vector<Expression *> &&expressions);
HashGroupByPhysicalOperator(vector<unique_ptr<Expression>> &&group_by_exprs, vector<Expression *> &&expressions);

virtual ~HashGroupByPhysicalOperator() = default;

Expand Down Expand Up @@ -58,5 +57,5 @@ class HashGroupByPhysicalOperator : public GroupByPhysicalOperator
vector<GroupType> groups_;

vector<GroupType>::iterator current_group_;
bool first_emited_ = false; /// 第一条数据是否已经输出
bool first_emited_ = false; /// 第一条数据是否已经输出
};
4 changes: 2 additions & 2 deletions src/observer/sql/operator/insert_logical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class InsertLogicalOperator : public LogicalOperator

LogicalOperatorType type() const override { return LogicalOperatorType::INSERT; }

Table *table() const { return table_; }
Table *table() const { return table_; }
const vector<Value> &values() const { return values_; }
vector<Value> &values() { return values_; }

private:
Table *table_ = nullptr;
Table *table_ = nullptr;
vector<Value> values_;
};
2 changes: 1 addition & 1 deletion src/observer/sql/operator/project_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ class ProjectPhysicalOperator : public PhysicalOperator
RC tuple_schema(TupleSchema &schema) const override;

private:
vector<unique_ptr<Expression>> expressions_;
vector<unique_ptr<Expression>> expressions_;
ExpressionTuple<unique_ptr<Expression>> tuple_;
};
2 changes: 1 addition & 1 deletion src/observer/sql/operator/project_vec_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ class ProjectVecPhysicalOperator : public PhysicalOperator

private:
vector<unique_ptr<Expression>> expressions_;
Chunk chunk_;
Chunk chunk_;
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ class ScalarGroupByPhysicalOperator : public GroupByPhysicalOperator

private:
unique_ptr<GroupValueType> group_value_;
bool emitted_ = false; /// 标识是否已经输出过
bool emitted_ = false; /// 标识是否已经输出过
};
4 changes: 2 additions & 2 deletions src/observer/sql/operator/string_list_physical_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class StringListPhysicalOperator : public PhysicalOperator
return nullptr;
}

const StringList &string_list = *iterator_;
vector<Value> cells;
const StringList &string_list = *iterator_;
vector<Value> cells;
for (const string &s : string_list) {

Value value(s.c_str());
Expand Down
4 changes: 2 additions & 2 deletions src/observer/sql/optimizer/optimize_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class OptimizeStage
* 而物理计划描述怎么做,比如如何从某张表按照什么条件获取什么数据,是否使用索引,使用哪个索引等。
* @param physical_operator 生成的物理计划。通常是一个多叉树的形状,这里就拿着根节点就可以了。
*/
RC generate_physical_plan(unique_ptr<LogicalOperator> &logical_operator,
unique_ptr<PhysicalOperator> &physical_operator, Session *session);
RC generate_physical_plan(
unique_ptr<LogicalOperator> &logical_operator, unique_ptr<PhysicalOperator> &physical_operator, Session *session);

private:
LogicalPlanGenerator logical_plan_generator_; ///< 根据SQL生成逻辑计划
Expand Down
3 changes: 1 addition & 2 deletions src/observer/sql/optimizer/predicate_pushdown_rewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class PredicatePushdownRewriter : public RewriteRule
RC rewrite(unique_ptr<LogicalOperator> &oper, bool &change_made) override;

private:
RC get_exprs_can_pushdown(
unique_ptr<Expression> &expr, vector<unique_ptr<Expression>> &pushdown_exprs);
RC get_exprs_can_pushdown(unique_ptr<Expression> &expr, vector<unique_ptr<Expression>> &pushdown_exprs);
bool is_empty_predicate(unique_ptr<Expression> &expr);
};
12 changes: 4 additions & 8 deletions src/observer/sql/parser/expression_binder.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ class ExpressionBinder
RC bind_expression(unique_ptr<Expression> &expr, vector<unique_ptr<Expression>> &bound_expressions);

private:
RC bind_star_expression(
unique_ptr<Expression> &star_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_star_expression(unique_ptr<Expression> &star_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_unbound_field_expression(
unique_ptr<Expression> &unbound_field_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_field_expression(
unique_ptr<Expression> &field_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_value_expression(
unique_ptr<Expression> &value_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_cast_expression(
unique_ptr<Expression> &cast_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_field_expression(unique_ptr<Expression> &field_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_value_expression(unique_ptr<Expression> &value_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_cast_expression(unique_ptr<Expression> &cast_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_comparison_expression(
unique_ptr<Expression> &comparison_expr, vector<unique_ptr<Expression>> &bound_expressions);
RC bind_conjunction_expression(
Expand Down
6 changes: 3 additions & 3 deletions src/observer/sql/parser/lex_sql.l
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ GROUP RETURN_TOKEN(GROUP);
BY RETURN_TOKEN(BY);
STORAGE RETURN_TOKEN(STORAGE);
FORMAT RETURN_TOKEN(FORMAT);
{ID} yylval->string=strdup(yytext); RETURN_TOKEN(ID);
{ID} yylval->cstring=strdup(yytext); RETURN_TOKEN(ID);
"(" RETURN_TOKEN(LBRACE);
")" RETURN_TOKEN(RBRACE);

Expand All @@ -136,8 +136,8 @@ FORMAT RETURN_TOKEN(FORMAT);
"-" |
"*" |
"/" { return yytext[0]; }
\"[^"]*\" yylval->string = strdup(yytext); RETURN_TOKEN(SSS);
'[^']*\' yylval->string = strdup(yytext); RETURN_TOKEN(SSS);
\"[^"]*\" yylval->cstring = strdup(yytext); RETURN_TOKEN(SSS);
'[^']*\' yylval->cstring = strdup(yytext); RETURN_TOKEN(SSS);

. LOG_DEBUG("Unknown character [%c]",yytext[0]); return yytext[0];
%%
Expand Down
16 changes: 8 additions & 8 deletions src/observer/sql/parser/parse_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct SelectSqlNode
{
vector<unique_ptr<Expression>> expressions; ///< 查询的表达式
vector<string> relations; ///< 查询的表
vector<ConditionSqlNode> conditions; ///< 查询条件,使用AND串联起来多个条件
vector<ConditionSqlNode> conditions; ///< 查询条件,使用AND串联起来多个条件
vector<unique_ptr<Expression>> group_by; ///< group by clause
};

Expand Down Expand Up @@ -131,7 +131,7 @@ struct UpdateSqlNode
{
string relation_name; ///< Relation to update
string attribute_name; ///< 更新的字段,仅支持一个字段
Value value; ///< 更新的值,仅支持一个字段
Value value; ///< 更新的值,仅支持一个字段
vector<ConditionSqlNode> conditions;
};

Expand All @@ -142,9 +142,9 @@ struct UpdateSqlNode
*/
struct AttrInfoSqlNode
{
AttrType type; ///< Type of attribute
string name; ///< Attribute name
size_t length; ///< Length of attribute
AttrType type; ///< Type of attribute
string name; ///< Attribute name
size_t length; ///< Length of attribute
};

/**
Expand Down Expand Up @@ -220,7 +220,7 @@ struct LoadDataSqlNode
struct SetVariableSqlNode
{
string name;
Value value;
Value value;
};

class ParsedSqlNode;
Expand All @@ -245,8 +245,8 @@ struct ExplainSqlNode
struct ErrorSqlNode
{
string error_msg;
int line;
int column;
int line;
int column;
};

/**
Expand Down
Loading

0 comments on commit 0936d27

Please sign in to comment.