CUBRID Engine  latest
xasl_analytic.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 //
20 // xasl_analytic - defines XASL structures for analytics
21 //
22 
23 #ifndef _XASL_ANALYTIC_HPP_
24 #define _XASL_ANALYTIC_HPP_
25 
26 #include "dbtype_def.h"
27 #include "regu_var.hpp" // regu_variable_node
28 #include "storage_common.h" // FUNC_TYPE, QUERY_OPTIONS
29 
30 // forward definitions
31 struct qfile_list_id;
32 struct sort_list;
33 typedef struct sort_list SORT_LIST; // todo - rename sort_list member.
34 struct tp_domain;
35 
36 namespace cubxasl
37 {
39  {
40  bool is_null; /* is function result NULL? */
41  int bucket_count; /* number of required buckets */
42  };
43 
45  {
46  int last_pos; /* record the current position of the rows that are no larger than the current row */
47  double last_res; /* record the last result */
48  };
49 
51  {
52  double cur_group_percentile; /* current percentile value */
53  regu_variable_node *percentile_reguvar; /* percentile value of the new tuple if this is not the same as
54  * cur_gourp_percentile, an error is raised. */
55  };
56 
58  {
62  };
63 
65  {
66  analytic_list_node *next; /* next analytic node */
67 
68  /* constant fields, XASL serialized */
69  FUNC_TYPE function; /* analytic function type */
70  QUERY_OPTIONS option; /* DISTINCT/ALL option */
71  tp_domain *domain; /* domain of the result */
72  tp_domain *original_domain; /* domain of the result */
73 
74  DB_TYPE opr_dbtype; /* operand data type */
75  DB_TYPE original_opr_dbtype; /* original operand data type */
76  regu_variable_node operand; /* operand */
77 
78  int flag; /* flags */
79  int sort_prefix_size; /* number of PARTITION BY cols in sort list */
80  int sort_list_size; /* the total size of the sort list */
81  int offset_idx; /* index of offset value in select list (for LEAD/LAG/NTH_value functions) */
82  int default_idx; /* index of default value in select list (for LEAD/LAG functions) */
83  bool from_last; /* begin at the last or first row */
84  bool ignore_nulls; /* ignore or respect NULL values */
85  bool is_const_operand; /* is the operand a constant or a host var for MEDIAN function */
86 
87  /* runtime values */
88  analytic_function_info info; /* custom function runtime values */
89  qfile_list_id *list_id; /* used for distinct handling */
90  db_value *value; /* value of the aggregate */
91  db_value *value2; /* for STTDEV and VARIANCE */
92  db_value *out_value; /* DB_VALUE used for output */
93  db_value part_value; /* partition temporary accumulator */
94  int curr_cnt; /* current number of items */
95  bool is_first_exec_time; /* the fist time to be executed */
96 
97  void init ();
98  };
99 
101  {
102  analytic_eval_type *next; /* next eval group */
103  analytic_list_node *head; /* analytic type list */
104  SORT_LIST *sort_list; /* partition sort */
105 
106  analytic_eval_type () = default;
107  };
108 } // namespace cubxasl
109 
116 
117 #endif // _XASL_ANALYTIC_HPP_
analytic_ntile_function_info ntile
analytic_cume_percent_function_info cume_percent
analytic_list_node * head
DB_TYPE
Definition: dbtype_def.h:670
analytic_eval_type * next
FUNC_TYPE
regu_variable_node operand
analytic_percentile_function_info percentile
analytic_function_info info
analytic_list_node * next
QUERY_OPTIONS