MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
aggregate_vec_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#pragma once
12
13#include "sql/operator/physical_operator.h"
14
20{
21public:
22 AggregateVecPhysicalOperator(vector<Expression *> &&expressions);
23
24 virtual ~AggregateVecPhysicalOperator() = default;
25
26 PhysicalOperatorType type() const override { return PhysicalOperatorType::AGGREGATE_VEC; }
27
28 RC open(Trx *trx) override;
29 RC next(Chunk &chunk) override;
30 RC close() override;
31
32private:
33 template <class STATE, typename T>
34 void update_aggregate_state(void *state, const Column &column);
35
36 template <class STATE, typename T>
37 void append_to_column(void *state, Column &column)
38 {
39 STATE *state_ptr = reinterpret_cast<STATE *>(state);
40 column.append_one((char *)&state_ptr->value);
41 }
42
43private:
45 {
46 public:
47 AggregateValues() = default;
48
49 void insert(void *aggr_value) { data_.push_back(aggr_value); }
50
51 void *at(size_t index)
52 {
53 ASSERT(index <= data_.size(), "index out of range");
54 return data_[index];
55 }
56
57 size_t size() { return data_.size(); }
59 {
60 for (auto &aggr_value : data_) {
61 free(aggr_value);
62 aggr_value = nullptr;
63 }
64 }
65
66 private:
67 vector<void *> data_;
68 };
69 vector<Expression *> aggregate_expressions_;
70 vector<Expression *> value_expressions_;
71 Chunk chunk_;
72 Chunk output_chunk_;
73 AggregateValues aggr_values_;
74};
Definition: aggregate_vec_physical_operator.h:45
聚合物理算子 (Vectorized)
Definition: aggregate_vec_physical_operator.h:20
vector< Expression * > value_expressions_
聚合表达式
Definition: aggregate_vec_physical_operator.h:70
A Chunk represents a set of columns.
Definition: chunk.h:23
A column contains multiple values in contiguous memory with a specified type.
Definition: column.h:22
与LogicalOperator对应,物理算子描述执行计划将如何执行
Definition: physical_operator.h:63
事务接口
Definition: trx.h:141
PhysicalOperatorType
物理算子类型
Definition: physical_operator.h:36