forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_expr_array_map.h
More file actions
118 lines (103 loc) · 4.23 KB
/
Copy pathob_expr_array_map.h
File metadata and controls
118 lines (103 loc) · 4.23 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Copyright (c) 2025 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OCEANBASE_SQL_OB_EXPR_ARRAY_MAP
#define OCEANBASE_SQL_OB_EXPR_ARRAY_MAP
#include "sql/engine/expr/ob_expr_operator.h"
#include "lib/udt/ob_array_type.h"
namespace oceanbase
{
namespace sql
{
// used in expr.extra_
struct ObExprArrayMapInfo : public ObIExprExtraInfo
{
OB_UNIS_VERSION(1);
public:
ObExprArrayMapInfo(common::ObIAllocator &alloc, ObExprOperatorType type)
: ObIExprExtraInfo(alloc, type),
allocator_(alloc),
param_exprs_(NULL),
param_num_(0),
param_idx_(NULL),
lambda_subschema_id_(UINT16_MAX)
{
}
virtual int deep_copy(common::ObIAllocator &allocator,
const ObExprOperatorType type,
ObIExprExtraInfo *&copied_info) const override;
public:
// for deserialize
common::ObIAllocator &allocator_;
ObExpr** param_exprs_;
int64_t param_num_;
uint32_t* param_idx_;
uint16_t lambda_subschema_id_;
};
class ObExprArrayMapCommon : public ObFuncExprOperator
{
public:
explicit ObExprArrayMapCommon(common::ObIAllocator &alloc,
ObExprOperatorType type,
const char *name,
int32_t param_num,
ObValidForGeneratedColFlag valid_for_generated_col,
int32_t dimension);
virtual ~ObExprArrayMapCommon();
protected:
static int eval_src_arrays(const ObExpr &expr, ObEvalCtx &ctx, ObArenaAllocator &tmp_allocator,
ObIArrayType **arr_obj, uint32_t &arr_dim, bool &is_null_res);
static int eval_lambda_array(ObEvalCtx &ctx, ObArenaAllocator &tmp_allocator, ObExprArrayMapInfo *info,
ObIArrayType **arr_obj, uint32_t arr_obj_size, uint32_t arr_dim,
ObExpr *lambda_expr, ObIArrayType *&lambda_arr);
static int set_lambda_para(ObIAllocator &alloc,
ObEvalCtx &ctx,
ObExprArrayMapInfo *info,
ObIArrayType **arr_obj,
uint32_t arr_obj_size,
uint32_t idx,
bool &is_set);
int get_array_map_lambda_params(const ObRawExpr *raw_expr, ObArray<uint32_t> ¶m_idx, int depth, ObArray<ObExpr *> ¶m_exprs) const;
int get_lambda_subschema_id(ObExecContext *exec_ctx,
const ObRawExpr &raw_expr,
uint16_t &lambda_subschema_id) const;
int construct_extra_info(ObExprCGCtx &expr_cg_ctx,
const ObRawExpr &raw_expr,
ObExpr &rt_expr,
ObIExprExtraInfo *&extra_info) const;
private:
DISALLOW_COPY_AND_ASSIGN(ObExprArrayMapCommon);
};
class ObExprArrayMap : public ObExprArrayMapCommon
{
public:
explicit ObExprArrayMap(common::ObIAllocator &alloc);
explicit ObExprArrayMap(common::ObIAllocator &alloc, ObExprOperatorType type,
const char *name, int32_t param_num, int32_t dimension);
virtual ~ObExprArrayMap();
virtual int calc_result_typeN(ObExprResType& type,
ObExprResType* types,
int64_t param_num,
common::ObExprTypeCtx& type_ctx) const override;
static int eval_array_map(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res);
virtual int cg_expr(ObExprCGCtx &expr_cg_ctx,
const ObRawExpr &raw_expr,
ObExpr &rt_expr) const override;
private:
DISALLOW_COPY_AND_ASSIGN(ObExprArrayMap);
};
} // sql
} // oceanbase
#endif // OCEANBASE_SQL_OB_EXPR_ARRAY_MAP