CUBRID Engine  latest
xasl_aggregate.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_aggregate.hpp - XASL structures used for aggregation
21 //
22 
23 #ifndef _XASL_AGGREGATE_HPP_
24 #define _XASL_AGGREGATE_HPP_
25 
26 #include "dbtype_def.h"
27 #include "storage_common.h"
28 
29 // forward definitions
30 struct qfile_list_id;
32 class regu_variable_node;
33 struct sort_list;
34 typedef struct sort_list SORT_LIST; // todo - rename sort_list member.
35 struct tp_domain;
36 
37 namespace cubxasl
38 {
40  {
41  double cur_group_percentile; /* current percentile value */
43  };
44 
45 #if defined (SERVER_MODE) || defined (SA_MODE)
46 
47  struct aggregate_dist_percent_info
48  {
49  DB_VALUE **const_array;
50  int list_len;
51  int nlargers;
52  };
53 #endif /* defined (SERVER_MODE) || defined (SA_MODE) */
54 
56  {
57  aggregate_percentile_info percentile; /* PERCENTILE_CONT and PERCENTILE_DISC */
58 #if defined (SERVER_MODE) || defined (SA_MODE)
59  aggregate_dist_percent_info dist_percent; /* CUME_DIST and PERCENT_RANK */
60 #endif /* defined (SERVER_MODE) || defined (SA_MODE) */
61  };
62 
64  {
65  db_value *value; /* value of the aggregate */
66  db_value *value2; /* for GROUP_CONCAT, STTDEV and VARIANCE */
67  int curr_cnt; /* current number of items */
68  bool clear_value_at_clone_decache; /* true, if need to clear value at clone decache */
69  bool clear_value2_at_clone_decache; /* true, if need to clear value2 at clone decache */
70  };
71 
72 #if defined (SERVER_MODE) || defined (SA_MODE)
73 
74  struct aggregate_accumulator_domain
75  {
76  tp_domain *value_dom; /* domain of value */
77  tp_domain *value2_dom; /* domain of value2 */
78  };
79 #endif /* defined (SERVER_MODE) || defined (SA_MODE) */
80 
82  {
83  aggregate_list_node *next; /* next aggregate node */
84  tp_domain *domain; /* domain of the result */
85  tp_domain *original_domain; /* original domain of the result */
86  FUNC_TYPE function; /* aggregate function name */
87  QUERY_OPTIONS option; /* DISTINCT/ALL option */
88  DB_TYPE opr_dbtype; /* Operand values data type */
89  DB_TYPE original_opr_dbtype; /* Original operand values data type */
90  regu_variable_list_node *operands; /* list of operands (one operand per function argument) */
91  qfile_list_id *list_id; /* used for distinct handling */
94  SORT_LIST *sort_list; /* for sorting elements before aggregation; used by GROUP_CONCAT */
95  aggregate_specific_function_info info; /* variables for specific functions */
96  aggregate_accumulator accumulator; /* holds runtime values, only for evaluation */
97 #if defined (SERVER_MODE) || defined (SA_MODE)
98  aggregate_accumulator_domain accumulator_domain; /* holds domain info on accumulator */
99 #endif /* defined (SERVER_MODE) || defined (SA_MODE) */
100  };
101 };
102 
103 // legacy aliases
108 
109 #if defined (SERVER_MODE) || defined (SA_MODE)
110 using AGGREGATE_DIST_PERCENT_INFO = cubxasl::aggregate_dist_percent_info;
111 using AGGREGATE_ACCUMULATOR_DOMAIN = cubxasl::aggregate_accumulator_domain;
112 #endif // server or SA mode
113 
114 #endif // _XASL_AGGREGATE_HPP_
aggregate_specific_function_info info
DB_TYPE
Definition: dbtype_def.h:670
FUNC_TYPE
aggregate_accumulator accumulator
regu_variable_node * percentile_reguvar
aggregate_list_node * next
regu_variable_list_node * operands
QUERY_OPTIONS