table_scan_operator.cpp 1.4 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
/* 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()
{
羽飞's avatar
羽飞 已提交
21 22 23 24 25 26
  RC rc = table_->get_record_scanner(record_scanner_);
  if (rc == RC::SUCCESS) {
    tuple_.set_table(table_);
    tuple_.set_schema(table_->table_meta().field_metas());
  }
  return rc;
W
wangyunlai.wyl 已提交
27 28 29 30 31 32 33 34 35
}

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

  RC rc = record_scanner_.next(current_record_);
羽飞's avatar
羽飞 已提交
36
  current_record_.set_fields(table_->table_meta().field_metas());
W
wangyunlai.wyl 已提交
37 38 39 40 41 42 43
  return rc;
}

RC TableScanOperator::close()
{
  return record_scanner_.close_scan();
}
羽飞's avatar
羽飞 已提交
44

羽飞's avatar
羽飞 已提交
45
Tuple * TableScanOperator::current_tuple()
羽飞's avatar
羽飞 已提交
46
{
羽飞's avatar
羽飞 已提交
47 48
  tuple_.set_record(&current_record_);
  return &tuple_;
羽飞's avatar
羽飞 已提交
49
}
羽飞's avatar
羽飞 已提交
50 51 52 53
RC TableScanOperator::tuple_cell_spec_at(int index, TupleCellSpec &spec) const
{
  return tuple_.cell_spec_at(index, spec);
}