提交 cd892de3 编写于 作者: 羽飞's avatar 羽飞

use Field instead of FieldDesc in select_stmt

上级 bc28950a
......@@ -266,8 +266,8 @@ RC ExecuteStage::do_select(SQLStageEvent *sql_event)
pred_oper.add_child(&table_scan_operator);
ProjectOperator project_oper;
project_oper.add_child(&pred_oper);
for (const FieldDesc &field : select_stmt->query_fields()) {
project_oper.add_projection(field.table_, field.field_meta_);
for (const Field &field : select_stmt->query_fields()) {
project_oper.add_projection(field.table(), field.meta());
}
rc = project_oper.open();
if (rc != RC::SUCCESS) {
......
......@@ -25,7 +25,7 @@ public:
virtual ~ProjectOperator() = default;
void add_projection(const Table *table, const FieldMeta *field); // TODO how to handle the memory in tupleCellSpec?
void add_projection(const Table *table, const FieldMeta *field);
RC open() override;
RC next() override;
......
......@@ -27,12 +27,12 @@ SelectStmt::~SelectStmt()
}
}
static void wildcard_fields(Table *table, std::vector<FieldDesc> &field_metas)
static void wildcard_fields(Table *table, std::vector<Field> &field_metas)
{
const TableMeta &table_meta = table->table_meta();
const int field_num = table_meta.field_num();
for (int i = table_meta.sys_field_num(); i < field_num; i++) {
field_metas.push_back(FieldDesc(table, table_meta.field(i)));
field_metas.push_back(Field(table, table_meta.field(i)));
}
}
......@@ -64,7 +64,7 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
}
// collect query fields in `select` statement
std::vector<FieldDesc> query_fields;
std::vector<Field> query_fields;
for (int i = select_sql.attr_num - 1; i >= 0; i--) {
const RelAttr &relation_attr = select_sql.attributes[i];
......@@ -102,7 +102,7 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
return RC::SCHEMA_FIELD_MISSING;
}
query_fields.push_back(FieldDesc(table, field_meta));
query_fields.push_back(Field(table, field_meta));
}
}
} else {
......@@ -118,7 +118,7 @@ RC SelectStmt::create(Db *db, const Selects &select_sql, Stmt *&stmt)
return RC::SCHEMA_FIELD_MISSING;
}
query_fields.push_back(FieldDesc(table, field_meta));
query_fields.push_back(Field(table, field_meta));
}
}
......
......@@ -18,22 +18,13 @@ See the Mulan PSL v2 for more details. */
#include "rc.h"
#include "sql/stmt/stmt.h"
#include "storage/common/field.h"
class FieldMeta;
class FilterStmt;
class Db;
class Table;
// TODO better to create a field class
struct FieldDesc
{
Table *table_ = nullptr;
const FieldMeta *field_meta_ = nullptr;
FieldDesc() = default;
FieldDesc(Table *table, const FieldMeta *field_meta) : table_(table), field_meta_(field_meta) {}
};
class SelectStmt : public Stmt
{
public:
......@@ -47,11 +38,11 @@ public:
public:
const std::vector<Table *> &tables() const { return tables_; }
const std::vector<FieldDesc> &query_fields() const { return query_fields_; }
const std::vector<Field> &query_fields() const { return query_fields_; }
FilterStmt *filter_stmt() const { return filter_stmt_; }
private:
std::vector<FieldDesc> query_fields_;
std::vector<Field> query_fields_;
std::vector<Table *> tables_;
FilterStmt *filter_stmt_ = nullptr;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册