MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
string_list_physical_operator.h
1/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
2miniob is licensed under Mulan PSL v2.
3You can use this software according to the terms and conditions of the Mulan PSL v2.
4You may obtain a copy of Mulan PSL v2 at:
5 http://license.coscl.org.cn/MulanPSL2
6THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
7EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
8MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9See the Mulan PSL v2 for more details. */
10
11//
12// Created by WangYunlai on 2022/11/18.
13//
14
15#pragma once
16
17#include "common/lang/initializer_list.h"
18#include "sql/operator/physical_operator.h"
19
26{
27public:
29
30 virtual ~StringListPhysicalOperator() = default;
31
32 template <typename InputIt>
33 void append(InputIt begin, InputIt end)
34 {
35 strings_.emplace_back(begin, end);
36 }
37
38 void append(initializer_list<string> init) { strings_.emplace_back(init); }
39
40 template <typename T>
41 void append(const T &v)
42 {
43 strings_.emplace_back(1, v);
44 }
45
46 PhysicalOperatorType type() const override { return PhysicalOperatorType::STRING_LIST; }
47
48 RC open(Trx *) override { return RC::SUCCESS; }
49
50 RC next() override
51 {
52 if (!started_) {
53 started_ = true;
54 iterator_ = strings_.begin();
55 } else if (iterator_ != strings_.end()) {
56 ++iterator_;
57 }
58 return iterator_ == strings_.end() ? RC::RECORD_EOF : RC::SUCCESS;
59 }
60
61 virtual RC close() override
62 {
63 iterator_ = strings_.end();
64 return RC::SUCCESS;
65 }
66
67 virtual Tuple *current_tuple() override
68 {
69 if (iterator_ == strings_.end()) {
70 return nullptr;
71 }
72
73 const StringList &string_list = *iterator_;
74 vector<Value> cells;
75 for (const string &s : string_list) {
76
77 Value value(s.c_str());
78 cells.push_back(value);
79 }
80 tuple_.set_cells(cells);
81 return &tuple_;
82 }
83
84private:
85 using StringList = vector<string>;
86 using StringListList = vector<StringList>;
87 StringListList strings_;
88 StringListList::iterator iterator_;
89 bool started_ = false;
90 ValueListTuple tuple_;
91};
与LogicalOperator对应,物理算子描述执行计划将如何执行
Definition: physical_operator.h:63
字符串列表物理算子
Definition: string_list_physical_operator.h:26
事务接口
Definition: trx.h:141
元组的抽象描述
Definition: tuple.h:66
一些常量值组成的TupleTODO 使用单独文件
Definition: tuple.h:312
属性的值
Definition: value.h:30
PhysicalOperatorType
物理算子类型
Definition: physical_operator.h:36