table_scan_operator.cpp 1.5 KB
Newer Older
W
wangyunlai.wyl 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/* 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/table_scan_operator.h"
#include "storage/common/table.h"
#include "rc.h"

RC TableScanOperator::open()
{
  return table_->get_record_scanner(record_scanner_);
}

RC TableScanOperator::next()
{
  if (!record_scanner_.has_next()) {
    return RC::RECORD_EOF;
  }

  RC rc = record_scanner_.next(current_record_);
羽飞's avatar
羽飞 已提交
31
  current_record_.set_fields(table_->table_meta().field_metas());
W
wangyunlai.wyl 已提交
32 33
  while (rc == RC::SUCCESS) {
    //if (predicate_ != nullptr && predicate_->filter(current_record_)) {
羽飞's avatar
羽飞 已提交
34
     return rc;
W
wangyunlai.wyl 已提交
35 36 37 38
    //}

    if (record_scanner_.has_next()) {
      rc = record_scanner_.next(current_record_);
羽飞's avatar
羽飞 已提交
39 40 41
      current_record_.set_fields(table_->table_meta().field_metas());
    } else {
      rc = RC::RECORD_EOF;
W
wangyunlai.wyl 已提交
42 43 44 45 46 47 48 49 50
    }
  }
  return rc;
}

RC TableScanOperator::close()
{
  return record_scanner_.close_scan();
}
羽飞's avatar
羽飞 已提交
51 52 53 54 55 56

RC TableScanOperator::current_record(Record &record)
{
  record = current_record_; // TODO should check status
  return RC::SUCCESS;
}