diff --git a/src/observer/sql/executor/execute_stage.cpp b/src/observer/sql/executor/execute_stage.cpp index 12479041039ec9a040a0f87af1d56bb94fa1675c..68105665426ed84a0fa55ffac2eebdd5090488d4 100644 --- a/src/observer/sql/executor/execute_stage.cpp +++ b/src/observer/sql/executor/execute_stage.cpp @@ -26,10 +26,10 @@ See the Mulan PSL v2 for more details. */ #include "event/sql_event.h" #include "event/session_event.h" #include "sql/executor/tuple.h" -#include "sql/executor/table_scan_operator.h" -#include "sql/executor/predicate_operator.h" -#include "sql/executor/delete_operator.h" -#include "sql/executor/project_operator.h" +#include "sql/operator/table_scan_operator.h" +#include "sql/operator/predicate_operator.h" +#include "sql/operator/delete_operator.h" +#include "sql/operator/project_operator.h" #include "sql/stmt/stmt.h" #include "sql/stmt/select_stmt.h" #include "sql/stmt/update_stmt.h" diff --git a/src/observer/sql/executor/execution_node.cpp.bak b/src/observer/sql/executor/execution_node.cpp.bak deleted file mode 100644 index 4533b6014db89da7d52cd8a3592d9eac2b806d23..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/execution_node.cpp.bak +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by Meiyi & Wangyunlai on 2021/5/14. -// - -#include "sql/executor/execution_node.h" -#include "storage/common/table.h" -#include "common/log/log.h" - -SelectExeNode::SelectExeNode() : table_(nullptr) -{} - -SelectExeNode::~SelectExeNode() -{ - for (DefaultConditionFilter *&filter : condition_filters_) { - delete filter; - } - condition_filters_.clear(); -} - -RC SelectExeNode::init( - Trx *trx, Table *table, TupleSchema &&tuple_schema, std::vector &&condition_filters) -{ - trx_ = trx; - table_ = table; - tuple_schema_ = tuple_schema; - condition_filters_ = std::move(condition_filters); - return RC::SUCCESS; -} - -void record_reader(const char *data, void *context) -{ - TupleRecordConverter *converter = (TupleRecordConverter *)context; - converter->add_record(data); -} -RC SelectExeNode::execute(TupleSet &tuple_set) -{ - CompositeConditionFilter condition_filter; - condition_filter.init((const ConditionFilter **)condition_filters_.data(), condition_filters_.size()); - - tuple_set.clear(); - tuple_set.set_schema(tuple_schema_); - TupleRecordConverter converter(table_, tuple_set); - return table_->scan_record(trx_, &condition_filter, -1, (void *)&converter, record_reader); -} \ No newline at end of file diff --git a/src/observer/sql/executor/execution_node.h b/src/observer/sql/executor/execution_node.h deleted file mode 100644 index 49362a57204676694fa772ec8b6c480110cfcdba..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/execution_node.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by Meiyi & Wangyunlai on 2021/5/13. -// - -#ifndef __OBSERVER_SQL_EXECUTOR_EXECUTION_NODE_H_ -#define __OBSERVER_SQL_EXECUTOR_EXECUTION_NODE_H_ - -#include -#include "storage/common/condition_filter.h" -#include "sql/executor/tuple.h" - -class Table; -class Trx; - -class ExecutionNode { -public: - ExecutionNode() = default; - virtual ~ExecutionNode() = default; - - virtual RC execute(TupleSet &tuple_set) = 0; -}; - -class SelectExeNode : public ExecutionNode { -public: - SelectExeNode(); - virtual ~SelectExeNode(); - - RC init( - Trx *trx, Table *table, TupleSchema &&tuple_schema, std::vector &&condition_filters); - - RC execute(TupleSet &tuple_set) override; - -private: - Trx *trx_ = nullptr; - Table *table_; - TupleSchema tuple_schema_; - std::vector condition_filters_; -}; - -#endif //__OBSERVER_SQL_EXECUTOR_EXECUTION_NODE_H_ diff --git a/src/observer/sql/executor/predicate.cpp b/src/observer/sql/executor/predicate.cpp deleted file mode 100644 index b8dfafa1b1f7e49f003e5331177540b644bd12ee..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/predicate.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by WangYunlai on 2021/6/9. -// - -#include "sql/executor/predicate.h" - - diff --git a/src/observer/sql/executor/predicate.h b/src/observer/sql/executor/predicate.h deleted file mode 100644 index 164b96e53017dcf7ab1e17cc8e19b6be06b3e288..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/predicate.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by WangYunlai on 2021/6/10. -// - -#pragma once - -class Predicate -{ -public: - Predicate() - {} - - virtual ~Predicate() = default; - - -private: -}; diff --git a/src/observer/sql/executor/tuple.cpp.bak b/src/observer/sql/executor/tuple.cpp.bak deleted file mode 100644 index 19e8a3e1180843c522cbfa5460e6dbc1f48652a3..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/tuple.cpp.bak +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by Meiyi & Wangyunlai on 2021/5/14. -// - -#include "sql/executor/tuple.h" -#include "storage/common/table.h" -#include "common/log/log.h" - -Tuple::Tuple(const Tuple &other) -{ - LOG_PANIC("Copy constructor of tuple is not supported"); - exit(1); -} - -Tuple::Tuple(Tuple &&other) noexcept : values_(std::move(other.values_)) -{} - -Tuple &Tuple::operator=(Tuple &&other) noexcept -{ - if (&other == this) { - return *this; - } - - values_.clear(); - values_.swap(other.values_); - return *this; -} - -Tuple::~Tuple() -{} - -// add (Value && value) -void Tuple::add(TupleValue *value) -{ - values_.emplace_back(value); -} -void Tuple::add(const std::shared_ptr &other) -{ - values_.emplace_back(other); -} -void Tuple::add(int value) -{ - add(new IntValue(value)); -} - -void Tuple::add(float value) -{ - add(new FloatValue(value)); -} - -void Tuple::add(const char *s, int len) -{ - add(new StringValue(s, len)); -} - -//////////////////////////////////////////////////////////////////////////////// - -std::string TupleField::to_string() const -{ - return std::string(table_name_) + "." + field_name_ + std::to_string(type_); -} - -//////////////////////////////////////////////////////////////////////////////// -void TupleSchema::from_table(const Table *table, TupleSchema &schema) -{ - const char *table_name = table->name(); - const TableMeta &table_meta = table->table_meta(); - const int field_num = table_meta.field_num(); - for (int i = 0; i < field_num; i++) { - const FieldMeta *field_meta = table_meta.field(i); - if (field_meta->visible()) { - schema.add(field_meta->type(), table_name, field_meta->name()); - } - } -} - -void TupleSchema::add(AttrType type, const char *table_name, const char *field_name) -{ - fields_.emplace_back(type, table_name, field_name); -} - -void TupleSchema::add_if_not_exists(AttrType type, const char *table_name, const char *field_name) -{ - for (const auto &field : fields_) { - if (0 == strcmp(field.table_name(), table_name) && 0 == strcmp(field.field_name(), field_name)) { - return; - } - } - - add(type, table_name, field_name); -} - -void TupleSchema::append(const TupleSchema &other) -{ - fields_.reserve(fields_.size() + other.fields_.size()); - for (const auto &field : other.fields_) { - fields_.emplace_back(field); - } -} - -int TupleSchema::index_of_field(const char *table_name, const char *field_name) const -{ - const int size = fields_.size(); - for (int i = 0; i < size; i++) { - const TupleField &field = fields_[i]; - if (0 == strcmp(field.table_name(), table_name) && 0 == strcmp(field.field_name(), field_name)) { - return i; - } - } - return -1; -} - -void TupleSchema::print(std::ostream &os) const -{ - if (fields_.empty()) { - os << "No schema"; - return; - } - - // 判断有多张表还是只有一张表 - std::set table_names; - for (const auto &field : fields_) { - table_names.insert(field.table_name()); - } - - for (std::vector::const_iterator iter = fields_.begin(), end = --fields_.end(); iter != end; ++iter) { - if (table_names.size() > 1) { - os << iter->table_name() << "."; - } - os << iter->field_name() << " | "; - } - - if (table_names.size() > 1) { - os << fields_.back().table_name() << "."; - } - os << fields_.back().field_name() << std::endl; -} - -///////////////////////////////////////////////////////////////////////////// -TupleSet::TupleSet(TupleSet &&other) : tuples_(std::move(other.tuples_)), schema_(other.schema_) -{ - other.schema_.clear(); -} - -TupleSet &TupleSet::operator=(TupleSet &&other) -{ - if (this == &other) { - return *this; - } - - schema_.clear(); - schema_.append(other.schema_); - other.schema_.clear(); - - tuples_.clear(); - tuples_.swap(other.tuples_); - return *this; -} - -void TupleSet::add(Tuple &&tuple) -{ - tuples_.emplace_back(std::move(tuple)); -} - -void TupleSet::clear() -{ - tuples_.clear(); - schema_.clear(); -} - -void TupleSet::print(std::ostream &os) const -{ - if (schema_.fields().empty()) { - LOG_WARN("Got empty schema"); - return; - } - - schema_.print(os); - - for (const Tuple &item : tuples_) { - const std::vector> &values = item.values(); - for (std::vector>::const_iterator iter = values.begin(), end = --values.end(); - iter != end; - ++iter) { - (*iter)->to_string(os); - os << " | "; - } - values.back()->to_string(os); - os << std::endl; - } -} - -void TupleSet::set_schema(const TupleSchema &schema) -{ - schema_ = schema; -} - -const TupleSchema &TupleSet::get_schema() const -{ - return schema_; -} - -bool TupleSet::is_empty() const -{ - return tuples_.empty(); -} - -int TupleSet::size() const -{ - return tuples_.size(); -} - -const Tuple &TupleSet::get(int index) const -{ - return tuples_[index]; -} - -const std::vector &TupleSet::tuples() const -{ - return tuples_; -} - -///////////////////////////////////////////////////////////////////////////// -TupleRecordConverter::TupleRecordConverter(Table *table, TupleSet &tuple_set) : table_(table), tuple_set_(tuple_set) -{} - -void TupleRecordConverter::add_record(const char *record) -{ - const TupleSchema &schema = tuple_set_.schema(); - Tuple tuple; - const TableMeta &table_meta = table_->table_meta(); - for (const TupleField &field : schema.fields()) { - const FieldMeta *field_meta = table_meta.field(field.field_name()); - assert(field_meta != nullptr); - switch (field_meta->type()) { - case INTS: { - int value = *(int *)(record + field_meta->offset()); - tuple.add(value); - } break; - case FLOATS: { - float value = *(float *)(record + field_meta->offset()); - tuple.add(value); - } break; - case CHARS: { - const char *s = record + field_meta->offset(); // 现在当做Cstring来处理 - tuple.add(s, strlen(s)); - } break; - default: { - LOG_PANIC("Unsupported field type. type=%d", field_meta->type()); - } - } - } - - tuple_set_.add(std::move(tuple)); -} diff --git a/src/observer/sql/executor/tuple.h b/src/observer/sql/executor/tuple.h index 35afdca08127beff08478e0ed4c5929ebc5f193c..c6216356d97be9c1a3973a4b8863d7ca1eb409ce 100644 --- a/src/observer/sql/executor/tuple.h +++ b/src/observer/sql/executor/tuple.h @@ -19,7 +19,6 @@ See the Mulan PSL v2 for more details. */ #include "common/log/log.h" #include "sql/parser/parse.h" -#include "sql/executor/value.h" #include "storage/common/field.h" #include "storage/common/record.h" diff --git a/src/observer/sql/executor/value.cpp b/src/observer/sql/executor/value.cpp deleted file mode 100644 index bfd64a8df10c0ba596cd209e2c757ea24a520262..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/value.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ diff --git a/src/observer/sql/executor/value.h b/src/observer/sql/executor/value.h deleted file mode 100644 index 88e8f077ba35cd4db1e780716f7fb95fc7714e86..0000000000000000000000000000000000000000 --- a/src/observer/sql/executor/value.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved. -miniob is licensed under Mulan PSL v2. -You can use this software according to the terms and conditions of the Mulan PSL v2. -You may obtain a copy of Mulan PSL v2 at: - http://license.coscl.org.cn/MulanPSL2 -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -See the Mulan PSL v2 for more details. */ - -// -// Created by Meiyi & Wangyunlai on 2021/5/14. -// - -#ifndef __OBSERVER_SQL_EXECUTOR_VALUE_H_ -#define __OBSERVER_SQL_EXECUTOR_VALUE_H_ - -#include - -#include -#include - -class TupleValue { -public: - TupleValue() = default; - virtual ~TupleValue() = default; - - virtual void to_string(std::ostream &os) const = 0; - virtual int compare(const TupleValue &other) const = 0; - -private: -}; - -class IntValue : public TupleValue { -public: - explicit IntValue(int value) : value_(value) - {} - - void to_string(std::ostream &os) const override - { - os << value_; - } - - int compare(const TupleValue &other) const override - { - const IntValue &int_other = (const IntValue &)other; - return value_ - int_other.value_; - } - -private: - int value_; -}; - -class FloatValue : public TupleValue { -public: - explicit FloatValue(float value) : value_(value) - {} - - void to_string(std::ostream &os) const override - { - os << value_; - } - - int compare(const TupleValue &other) const override - { - const FloatValue &float_other = (const FloatValue &)other; - float result = value_ - float_other.value_; - if (result > 0) { // 浮点数没有考虑精度问题 - return 1; - } - if (result < 0) { - return -1; - } - return 0; - } - -private: - float value_; -}; - -class StringValue : public TupleValue { -public: - StringValue(const char *value, int len) : value_(value, len) - {} - explicit StringValue(const char *value) : value_(value) - {} - - void to_string(std::ostream &os) const override - { - os << value_; - } - - int compare(const TupleValue &other) const override - { - const StringValue &string_other = (const StringValue &)other; - return strcmp(value_.c_str(), string_other.value_.c_str()); - } - -private: - std::string value_; -}; - -#endif //__OBSERVER_SQL_EXECUTOR_VALUE_H_ diff --git a/src/observer/sql/executor/delete_operator.cpp b/src/observer/sql/operator/delete_operator.cpp similarity index 97% rename from src/observer/sql/executor/delete_operator.cpp rename to src/observer/sql/operator/delete_operator.cpp index f6757e92b7d71f1bd5d209f79a2d53caae4ba335..88f88c703395fafae246ba0ee382b31a066ef1d1 100644 --- a/src/observer/sql/executor/delete_operator.cpp +++ b/src/observer/sql/operator/delete_operator.cpp @@ -13,7 +13,7 @@ See the Mulan PSL v2 for more details. */ // #include "common/log/log.h" -#include "sql/executor/delete_operator.h" +#include "sql/operator/delete_operator.h" #include "storage/common/record.h" #include "storage/common/table.h" #include "sql/stmt/delete_stmt.h" diff --git a/src/observer/sql/executor/delete_operator.h b/src/observer/sql/operator/delete_operator.h similarity index 97% rename from src/observer/sql/executor/delete_operator.h rename to src/observer/sql/operator/delete_operator.h index 983229463af964e1db70f6b1eeeca664166988d9..57ee275ab770d681dd990db0714da11408fee7df 100644 --- a/src/observer/sql/executor/delete_operator.h +++ b/src/observer/sql/operator/delete_operator.h @@ -14,7 +14,7 @@ See the Mulan PSL v2 for more details. */ #pragma once -#include "sql/executor/operator.h" +#include "sql/operator/operator.h" #include "rc.h" class DeleteStmt; diff --git a/src/observer/sql/executor/insert_operator.cpp b/src/observer/sql/operator/insert_operator.cpp similarity index 96% rename from src/observer/sql/executor/insert_operator.cpp rename to src/observer/sql/operator/insert_operator.cpp index a92362e28b1447d05021f9c41e729d08da1b9eb8..89f358ef1d452d94d8fbf8b42f1db8a3bb8d7bde 100644 --- a/src/observer/sql/executor/insert_operator.cpp +++ b/src/observer/sql/operator/insert_operator.cpp @@ -12,7 +12,7 @@ See the Mulan PSL v2 for more details. */ // Created by WangYunlai on 2021/6/9. // -#include "sql/executor/insert_operator.h" +#include "sql/operator/insert_operator.h" #include "sql/stmt/insert_stmt.h" #include "storage/common/table.h" #include "rc.h" diff --git a/src/observer/sql/executor/insert_operator.h b/src/observer/sql/operator/insert_operator.h similarity index 93% rename from src/observer/sql/executor/insert_operator.h rename to src/observer/sql/operator/insert_operator.h index a501cb8cfe4617246ffb955e294461d9a725a46b..0e0135a2ccca89e29e96310835452e6e1bb7396f 100644 --- a/src/observer/sql/executor/insert_operator.h +++ b/src/observer/sql/operator/insert_operator.h @@ -14,8 +14,7 @@ See the Mulan PSL v2 for more details. */ #pragma once -#include "common/seda/stage.h" -#include "sql/executor/operator.h" +#include "sql/operator/operator.h" #include "sql/parser/parse.h" #include "rc.h" diff --git a/src/observer/sql/executor/join_operator.cpp.bak b/src/observer/sql/operator/join_operator.cpp.bak similarity index 97% rename from src/observer/sql/executor/join_operator.cpp.bak rename to src/observer/sql/operator/join_operator.cpp.bak index 19dd5864bb276a751b12465f6e5b85e362d4c762..f0f8e6315c7e1726482fceaf042127e96e80f5d6 100644 --- a/src/observer/sql/executor/join_operator.cpp.bak +++ b/src/observer/sql/operator/join_operator.cpp.bak @@ -12,7 +12,7 @@ See the Mulan PSL v2 for more details. */ // Created by WangYunlai on 2021/6/10. // -#include "sql/executor/join_operator.h" +#include "sql/operator/join_operator.h" RC JoinOperator::open() { diff --git a/src/observer/sql/executor/join_operator.h b/src/observer/sql/operator/join_operator.h similarity index 96% rename from src/observer/sql/executor/join_operator.h rename to src/observer/sql/operator/join_operator.h index 538c93c7e8393b2cd067ff76d83e391a6849e391..4bfe26136a25c8f376289359d25911cdc21ff067 100644 --- a/src/observer/sql/executor/join_operator.h +++ b/src/observer/sql/operator/join_operator.h @@ -15,7 +15,7 @@ See the Mulan PSL v2 for more details. */ #pragma once #include "sql/parser/parse.h" -#include "sql/executor/operator.h" +#include "sql/operator/operator.h" #include "rc.h" class JoinPredicate; diff --git a/src/observer/sql/executor/operator.h b/src/observer/sql/operator/operator.h similarity index 100% rename from src/observer/sql/executor/operator.h rename to src/observer/sql/operator/operator.h diff --git a/src/observer/sql/executor/predicate_operator.cpp b/src/observer/sql/operator/predicate_operator.cpp similarity index 98% rename from src/observer/sql/executor/predicate_operator.cpp rename to src/observer/sql/operator/predicate_operator.cpp index d349afc2f7de660f92784119c28d1fe194c4dbff..3eee630f751968e228ca38a99ff3144a87ac6fa4 100644 --- a/src/observer/sql/executor/predicate_operator.cpp +++ b/src/observer/sql/operator/predicate_operator.cpp @@ -13,7 +13,7 @@ See the Mulan PSL v2 for more details. */ // #include "common/log/log.h" -#include "sql/executor/predicate_operator.h" +#include "sql/operator/predicate_operator.h" #include "storage/common/record.h" #include "sql/stmt/filter_stmt.h" #include "storage/common/field.h" diff --git a/src/observer/sql/executor/predicate_operator.h b/src/observer/sql/operator/predicate_operator.h similarity index 97% rename from src/observer/sql/executor/predicate_operator.h rename to src/observer/sql/operator/predicate_operator.h index acc35398afa1b567e70778948abca3eefd8bb6b7..1c375aafcfcca076e80b0551f6430868340f1991 100644 --- a/src/observer/sql/executor/predicate_operator.h +++ b/src/observer/sql/operator/predicate_operator.h @@ -14,7 +14,7 @@ See the Mulan PSL v2 for more details. */ #pragma once -#include "sql/executor/operator.h" +#include "sql/operator/operator.h" class FilterStmt; class PredicateOperator : public Operator diff --git a/src/observer/sql/executor/project_operator.cpp b/src/observer/sql/operator/project_operator.cpp similarity index 97% rename from src/observer/sql/executor/project_operator.cpp rename to src/observer/sql/operator/project_operator.cpp index 396a1c1c33d40c349243f9ad8e1f322893fd3bae..62688e1d9660b3b477d82cf28c26a7d8782e62ee 100644 --- a/src/observer/sql/executor/project_operator.cpp +++ b/src/observer/sql/operator/project_operator.cpp @@ -13,7 +13,7 @@ See the Mulan PSL v2 for more details. */ // #include "common/log/log.h" -#include "sql/executor/project_operator.h" +#include "sql/operator/project_operator.h" #include "storage/common/record.h" #include "storage/common/table.h" diff --git a/src/observer/sql/executor/project_operator.h b/src/observer/sql/operator/project_operator.h similarity index 97% rename from src/observer/sql/executor/project_operator.h rename to src/observer/sql/operator/project_operator.h index 0ac687d34512d36acbc524f3d3ee24f517e31eb7..599625eca406184c8c8ad184250de7fd6631b1a4 100644 --- a/src/observer/sql/executor/project_operator.h +++ b/src/observer/sql/operator/project_operator.h @@ -14,7 +14,7 @@ See the Mulan PSL v2 for more details. */ #pragma once -#include "sql/executor/operator.h" +#include "sql/operator/operator.h" #include "rc.h" class ProjectOperator : public Operator diff --git a/src/observer/sql/executor/table_scan_operator.cpp b/src/observer/sql/operator/table_scan_operator.cpp similarity index 92% rename from src/observer/sql/executor/table_scan_operator.cpp rename to src/observer/sql/operator/table_scan_operator.cpp index c4354da1608d70d6a445573096679ceeb5c23cd9..637fc778043581c9227b5830007ae217f31b90ca 100644 --- a/src/observer/sql/executor/table_scan_operator.cpp +++ b/src/observer/sql/operator/table_scan_operator.cpp @@ -12,7 +12,7 @@ See the Mulan PSL v2 for more details. */ // Created by WangYunlai on 2021/6/9. // -#include "sql/executor/table_scan_operator.h" +#include "sql/operator/table_scan_operator.h" #include "storage/common/table.h" #include "rc.h" @@ -33,7 +33,6 @@ RC TableScanOperator::next() } RC rc = record_scanner_.next(current_record_); - current_record_.set_fields(table_->table_meta().field_metas()); return rc; } diff --git a/src/observer/sql/executor/table_scan_operator.h b/src/observer/sql/operator/table_scan_operator.h similarity index 93% rename from src/observer/sql/executor/table_scan_operator.h rename to src/observer/sql/operator/table_scan_operator.h index 19a3092c04f03e44887149fe6a46809c50b1ce06..5848f67834235ec025f076046065db54788d94a1 100644 --- a/src/observer/sql/executor/table_scan_operator.h +++ b/src/observer/sql/operator/table_scan_operator.h @@ -14,13 +14,11 @@ See the Mulan PSL v2 for more details. */ #pragma once -#include "sql/executor/predicate.h" -#include "sql/executor/operator.h" +#include "sql/operator/operator.h" #include "storage/common/record_manager.h" #include "rc.h" class Table; -class Predicate; class TableScanOperator : public Operator { diff --git a/src/observer/storage/common/record.cpp b/src/observer/storage/common/record.cpp index 40ee00022f632866c4fd084dbf487c3de0472ccd..3f35dce2e4564993d4f15abc7dc5f198ed61ed1b 100644 --- a/src/observer/storage/common/record.cpp +++ b/src/observer/storage/common/record.cpp @@ -2,15 +2,3 @@ #include "storage/common/field.h" #include "common/log/log.h" #include "rc.h" - -RC Record::set_field_value(const Value &value, int index) -{ - // TODO - return RC::UNIMPLENMENT; -} - -RC Record::set_field_values(const Value *values, int value_num, int start_index) -{ - // TODO - return RC::UNIMPLENMENT; -} diff --git a/src/observer/storage/common/record.h b/src/observer/storage/common/record.h index 09c5764537d0266c7070056799e140a250f187c2..963a37147c8a942d7389a6325ccf3807e040b7b9 100644 --- a/src/observer/storage/common/record.h +++ b/src/observer/storage/common/record.h @@ -91,22 +91,12 @@ public: char *data() { return this->data_; } const char *data() const { return this->data_; } - void set_fields(const std::vector *fields) { this->fields_ = fields; } - const std::vector *field_metas() const { return fields_; } - - RC field_at(int index, Field &field) const; - int field_amount() const { return fields_->size();} - void set_rid(const RID &rid) { this->rid_ = rid; } void set_rid(const PageNum page_num, const SlotNum slot_num) { this->rid_.page_num = page_num; this->rid_.slot_num = slot_num; } RID & rid() { return rid_; } const RID &rid() const { return rid_; }; - RC set_field_value(const Value &value, int index); - RC set_field_values(const Value *values, int value_num, int start_index); - private: - const std::vector * fields_ = nullptr; RID rid_; // the data buffer