CUBRID Engine  latest
partition_sr.h
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  * Partition pruning on server
21  */
22 
23 #ifndef _PARTITION_SR_H_
24 #define _PARTITION_SR_H_
25 
26 #if !defined (SERVER_MODE) && !defined (SA_MODE)
27 #error Belongs to server module
28 #endif /* !defined (SERVER_MODE) && !defined (SA_MODE) */
29 
30 #include "heap_file.h"
31 #include "thread_compat.hpp"
32 
33 // forward definition
34 struct access_spec_node;
35 struct func_pred;
37 struct val_descr;
38 struct xasl_unpack_info;
39 
40 // *INDENT-OFF*
41 namespace cubquery
42 {
44 }
46 // *INDENT-ON*
47 
48 /* object for caching objects used in multi row modify statements for each partition */
51 {
52  HEAP_SCANCACHE scan_cache; /* cached partition heap info */
53  bool is_scan_cache_started; /* true if cache has been started */
54  func_pred_unpack_info *func_index_pred; /* an array of function indexes cached for repeated evaluation */
55  int n_indexes; /* number of indexes */
56 };
57 
58 /* linked list for caching PRUNING_SCAN_CACHE objects in the pruning context */
61 {
64 };
65 
68 {
69  THREAD_ENTRY *thread_p; /* current thread */
70  OID root_oid; /* OID of the root class */
71  REPR_ID root_repr_id; /* root class representation id */
72  access_spec_node *spec; /* class to prune */
73  val_descr *vd; /* value descriptor */
74  DB_PARTITION_TYPE partition_type; /* hash, range, list */
75 
76  OR_PARTITION *partitions; /* partitions array */
77  OR_PARTITION *selected_partition; /* if a request was made on a partition rather than on the root class, this
78  * holds the partition info */
79  SCANCACHE_LIST *scan_cache_list; /* caches for partitions affected by the query using this context */
80  int count; /* number of partitions */
81 
82  xasl_unpack_info *fp_cache_context; /* unpacking info */
83  func_pred *partition_pred; /* partition predicate */
84  int attr_position; /* attribute position in index key */
85  ATTR_ID attr_id; /* id of the attribute which defines the partitions */
86  HEAP_CACHE_ATTRINFO attr_info; /* attribute info cache for the partition expression */
87  int error_code; /* error encountered during pruning */
88 
89  int pruning_type; /* The type of the class for which this context was loaded. DB_PARTITIONED_CLASS,
90  * DB_PARTITION_CLASS */
92  bool is_from_cache; /* true if this context is cached */
93 };
94 
96 
97 extern int partition_load_pruning_context (THREAD_ENTRY * thread_p, const OID * class_oid, int pruning_type,
98  PRUNING_CONTEXT * pinfo);
99 
101 
102 extern int partition_cache_init (THREAD_ENTRY * thread_p);
103 
104 extern void partition_cache_finalize (THREAD_ENTRY * thread_p);
105 
106 extern void partition_decache_class (THREAD_ENTRY * thread_p, const OID * class_oid);
107 
108 extern PRUNING_SCAN_CACHE *partition_get_scancache (PRUNING_CONTEXT * pcontext, const OID * partition_oid);
109 
111 
112 extern int partition_prune_spec (THREAD_ENTRY * thread_p, val_descr * vd, access_spec_node * access_spec);
113 
114 extern int partition_prune_insert (THREAD_ENTRY * thread_p, const OID * class_oid, RECDES * recdes,
115  HEAP_SCANCACHE * scan_cache, PRUNING_CONTEXT * pcontext, int op_type,
116  OID * pruned_class_oid, HFID * pruned_hfid, OID * superclass_oid);
117 
118 extern int partition_prune_update (THREAD_ENTRY * thread_p, const OID * class_oid, RECDES * recdes,
119  PRUNING_CONTEXT * pcontext, int pruning_type, OID * pruned_class_oid,
120  HFID * pruned_hfid, OID * superclass_oid);
121 
122 extern int partition_prune_unique_btid (PRUNING_CONTEXT * pcontext, DB_VALUE * key, OID * class_oid, HFID * class_hfid,
123  BTID * btid);
124 
125 extern int partition_get_partition_oids (THREAD_ENTRY * thread_p, const OID * class_oid, OID ** partition_oids,
126  int *count);
127 
128 extern int partition_load_aggregate_helper (PRUNING_CONTEXT * pcontext, access_spec_node * spec, int pruned_count,
129  BTID * root_btid, HIERARCHY_AGGREGATE_HELPER * helper);
130 #if 0
131 extern int partition_is_global_index (THREAD_ENTRY * thread_p, PRUNING_CONTEXT * contextp, OID * class_oid, BTID * btid,
132  BTREE_TYPE * btree_typep, int *is_global_index);
133 #endif
134 
135 extern int partition_find_root_class_oid (THREAD_ENTRY * thread_p, const OID * class_oid, OID * super_oid);
136 
137 extern int partition_prune_partition_index (PRUNING_CONTEXT * pcontext, DB_VALUE * key, OID * class_oid,
138  BTID * btid, int *position);
139 
140 #endif /* _PARTITION_SR_H_ */
HEAP_CACHE_ATTRINFO attr_info
Definition: partition_sr.h:86
SCANCACHE_LIST * next
Definition: partition_sr.h:62
int partition_prune_partition_index(PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, BTID *btid, int *position)
Definition: partition.c:3926
BTREE_TYPE
OR_PARTITION * selected_partition
Definition: partition_sr.h:77
int partition_cache_init(THREAD_ENTRY *thread_p)
Definition: partition.c:711
val_descr * vd
Definition: partition_sr.h:73
func_pred * partition_pred
Definition: partition_sr.h:83
xasl_unpack_info * fp_cache_context
Definition: partition_sr.h:82
int partition_prune_update(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes, PRUNING_CONTEXT *pcontext, int pruning_type, OID *pruned_class_oid, HFID *pruned_hfid, OID *superclass_oid)
Definition: partition.c:3199
REPR_ID root_repr_id
Definition: partition_sr.h:71
void partition_cache_finalize(THREAD_ENTRY *thread_p)
Definition: partition.c:748
void THREAD_ENTRY
int ATTR_ID
int partition_load_pruning_context(THREAD_ENTRY *thread_p, const OID *class_oid, int pruning_type, PRUNING_CONTEXT *pinfo)
Definition: partition.c:2249
int partition_get_partition_oids(THREAD_ENTRY *thread_p, const OID *class_oid, OID **partition_oids, int *count)
Definition: partition.c:3380
bool is_attr_info_inited
Definition: partition_sr.h:91
PRUNING_SCAN_CACHE scan_cache
Definition: partition_sr.h:63
THREAD_ENTRY * thread_p
Definition: partition_sr.h:69
PRUNING_SCAN_CACHE * partition_new_scancache(PRUNING_CONTEXT *pcontext)
Definition: partition.c:3350
int partition_prune_insert(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, PRUNING_CONTEXT *pcontext, int op_type, OID *pruned_class_oid, HFID *pruned_hfid, OID *superclass_oid)
Definition: partition.c:3092
access_spec_node * spec
Definition: partition_sr.h:72
OR_PARTITION * partitions
Definition: partition_sr.h:76
void partition_init_pruning_context(PRUNING_CONTEXT *pinfo)
Definition: partition.c:2164
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
DB_PARTITION_TYPE partition_type
Definition: partition_sr.h:74
DB_PARTITION_TYPE
SCANCACHE_LIST * scan_cache_list
Definition: partition_sr.h:79
int partition_prune_unique_btid(PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, HFID *class_hfid, BTID *btid)
Definition: partition.c:3553
void partition_clear_pruning_context(PRUNING_CONTEXT *pinfo)
Definition: partition.c:2380
PRUNING_SCAN_CACHE * partition_get_scancache(PRUNING_CONTEXT *pcontext, const OID *partition_oid)
Definition: partition.c:3320
void partition_decache_class(THREAD_ENTRY *thread_p, const OID *class_oid)
Definition: partition.c:775
int partition_prune_spec(THREAD_ENTRY *thread_p, val_descr *vd, access_spec_node *access_spec)
Definition: partition.c:2841
int REPR_ID
int partition_load_aggregate_helper(PRUNING_CONTEXT *pcontext, access_spec_node *spec, int pruned_count, BTID *root_btid, HIERARCHY_AGGREGATE_HELPER *helper)
Definition: partition.c:3639
int partition_find_root_class_oid(THREAD_ENTRY *thread_p, const OID *class_oid, OID *super_oid)
Definition: partition.c:2199
HEAP_SCANCACHE scan_cache
Definition: partition_sr.h:52
func_pred_unpack_info * func_index_pred
Definition: partition_sr.h:54