Debian Codegraph @

storage/innobase/include/gis0rtree.inl

raw symbols SCIP
1 /*****************************************************************************
2
3 Copyright (c) 2014, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2017, 2023, MariaDB Corporation.
5
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17
18 *****************************************************************************/
19
20 /******************************************************************//**
21 @file include gis0rtree.h
22 R-tree Inline code
23
24 Created 2013/03/27 Jimmy Yang and Allen Lai
25 ***********************************************************************/
26
27 /**************************************************************//**
28 Sets the child node mbr in a node pointer. */
29 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
30 void
31 rtr_page_cal_mbrcxx . . $ rtr_page_cal_mbr(1f38fadbdcdad140).(
32 /*=============*/
33 const dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index */
34 const buf_block_tcxx . . $ buf_block_t#* block, /*!< in: buffer block */
35 rtr_mbr_tcxx . . $ rtr_mbr_t#* rtr_mbr,/*!< out: MBR encapsulates the page */
36 mem_heap_tcxx . . $ mem_heap_t#* heap) /*!< in: heap for the memory
37 allocation */
38 {
39 page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page;
40 rec_tcxx . . $ rec_t#* rec;
41 const bytecxx . . $ byte#* field;
42 ulintcxx . . $ ulint# len;
43 rec_offscxx . . $ rec_offs#* offsets = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
44 double bmin, bmax;
45 double* amin;
46 double* amax;
47 ulintcxx . . $ ulint# inc = 0;
48 double* mbr;
49
50 rtr_mbr->xmincxx . . $ rtr_mbr#xmin. = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
51 rtr_mbr->ymincxx . . $ rtr_mbr#ymin. = DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
52 rtr_mbr->xmaxcxx . . $ rtr_mbr#xmax. = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
53 rtr_mbr->ymaxcxx . . $ rtr_mbr#ymax. = -DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!;
54
55 mbr = reinterpret_cast<double*>(rtr_mbr);
56
57 page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block);
58
59 rec = page_rec_get_nextcxx . . $ page_rec_get_next(adcd832f8377c3d8).(page_get_infimum_reccxx . . $ `storage/innobase/include/page0page.h:531:9`!(page));
60 if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!rec)) {
61 return;
62 }
63 offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, index, offsets, page_is_leaf(page)
64 ? index->n_fields : 0,
65 ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap);
66
67 do {
68 /* The mbr address is in the first field. */
69 field = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, 0, &len);
70
71 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == DATA_MBR_LEN);
72 inc = 0;
73 for (unsigned i = 0; i < SPDIMScxx . . $ `storage/innobase/include/univ.i:455:9`!; i++) {
74 bmin = mach_double_readcxx . . $ mach_double_read(f9495cbc5cbb25f1).(field + inc);
75 bmax = mach_double_readcxx . . $ mach_double_read(f9495cbc5cbb25f1).(field + inc + sizeof(double));
76
77 amin = mbr + i * SPDIMScxx . . $ `storage/innobase/include/univ.i:455:9`!;
78 amax = mbr + i * SPDIMScxx . . $ `storage/innobase/include/univ.i:455:9`! + 1;
79
80 if (*amin > bmin)
81 *amin = bmin;
82 if (*amax < bmax)
83 *amax = bmax;
84
85 inc += 2 * sizeof(double);
86 }
87
88 rec = page_rec_get_nextcxx . . $ page_rec_get_next(adcd832f8377c3d8).(rec);
89
90 if (rec == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
91 break;
92 }
93 } while (!page_rec_is_supremumcxx . . $ page_rec_is_supremum(190063cf6fb4afb1).(rec));
94 }
95
96 /**************************************************************//**
97 push a nonleaf index node to the search path */
98 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
99 void
100 rtr_non_leaf_stack_pushcxx . . $ rtr_non_leaf_stack_push(9734031e7397d196).(
101 /*====================*/
102 rtr_node_path_tcxx . . $ rtr_node_path_t#* path, /*!< in/out: search path */
103 uint32_tcxx . . $ uint32_t# pageno, /*!< in: pageno to insert */
104 node_seq_tcxx . . $ node_seq_t# seq_no, /*!< in: Node sequence num */
105 ulintcxx . . $ ulint# level, /*!< in: index page level */
106 uint32_tcxx . . $ uint32_t# child_no, /*!< in: child page no */
107 btr_pcur_tcxx . . $ btr_pcur_t#* cursor, /*!< in: position cursor */
108 double mbr_inc) /*!< in: MBR needs to be
109 enlarged */
110 {
111 node_visit_tcxx . . $ node_visit_t# insert_val;
112
113 insert_val.page_nocxx . . $ node_visit_t#page_no. = pageno;
114 insert_val.seq_nocxx . . $ node_visit_t#seq_no. = seq_no;
115 insert_val.levelcxx . . $ node_visit_t#level. = level;
116 insert_val.child_nocxx . . $ node_visit_t#child_no. = child_no;
117 insert_val.cursorcxx . . $ node_visit_t#cursor. = cursor;
118 insert_val.mbr_inccxx . . $ node_visit_t#mbr_inc. = mbr_inc;
119
120 path->push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(insert_val);
121
122 #ifdef RTR_SEARCH_DIAGNOSTIC
123 fprintf(stderr, "INNODB_RTR: Push page %d, level %d, seq %d"
124 " to search stack \n",
125 static_cast<int>(pageno), static_cast<int>(level),
126 static_cast<int>(seq_no));
127 #endif /* RTR_SEARCH_DIAGNOSTIC */
128 }
129
130 /*********************************************************************//**
131 Sets pointer to the data and length in a field. */
132 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
133 void
134 rtr_write_mbrcxx . . $ rtr_write_mbr(c246b367350631aa).(
135 /*==========*/
136 bytecxx . . $ byte#* data, /*!< out: data */
137 const rtr_mbr_tcxx . . $ rtr_mbr_t#* mbr) /*!< in: data */
138 {
139 const double* my_mbr = reinterpret_cast<const double*>(mbr);
140
141 for (unsigned i = 0; i < SPDIMScxx . . $ `storage/innobase/include/univ.i:455:9`! * 2; i++) {
142 mach_double_writecxx . . $ mach_double_write(17d12369f88f69ef).(data + i * sizeof(double), my_mbr[i]);
143 }
144 }
145
146 /*********************************************************************//**
147 Sets pointer to the data and length in a field. */
148 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
149 void
150 rtr_read_mbrcxx . . $ rtr_read_mbr(6f8069964988d1d0).(
151 /*==========*/
152 const bytecxx . . $ byte#* data, /*!< in: data */
153 rtr_mbr_tcxx . . $ rtr_mbr_t#* mbr) /*!< out: MBR */
154 {
155 for (unsigned i = 0; i < SPDIMScxx . . $ `storage/innobase/include/univ.i:455:9`! * 2; i++) {
156 (reinterpret_cast<double*>(mbr))[i] = mach_double_readcxx . . $ mach_double_read(f9495cbc5cbb25f1).(
157 data
158 + i * sizeof(double));
159 }
160 }
161
162 /*********************************************************//**
163 Returns the R-Tree node stored in the parent search path
164 @return pointer to R-Tree cursor component in the parent path,
165 NULL if parent path is empty or index is larger than num of items contained */
166 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
167 node_visit_tcxx . . $ node_visit_t#*
168 rtr_get_parent_nodecxx . . $ rtr_get_parent_node(1e31f6e0524f29af).(
169 /*================*/
170 btr_cur_tcxx . . $ btr_cur_t#* btr_cur, /*!< in: persistent cursor */
171 ulintcxx . . $ ulint# level, /*!< in: index level of buffer page */
172 ulintcxx . . $ ulint# is_insert) /*!< in: whether it is insert */
173 {
174 ulintcxx . . $ ulint# num;
175 ulintcxx . . $ ulint# tree_height = btr_cur->tree_heightcxx . . $ btr_cur_t#tree_height.;
176 node_visit_tcxx . . $ node_visit_t#* found_node = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
177
178 if (level >= tree_height) {
179 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
180 }
181
182 mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&btr_cur->rtr_info->rtr_path_mutex);
183
184 num = btr_cur->rtr_infocxx . . $ btr_cur_t#rtr_info.->parent_pathcxx . . $ rtr_info#parent_path.->sizecxx . . $ std/vector#size(c9b1e749b64d5edc).();
185
186 if (!num) {
187 mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&btr_cur->rtr_info->rtr_path_mutex);
188 return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
189 }
190
191 if (is_insert) {
192 ulintcxx . . $ ulint# idx = tree_height - level - 1;
193 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(idx < num);
194
195 found_node = &(*btr_cur->rtr_infocxx . . $ btr_cur_t#rtr_info.->parent_pathcxx . . $ rtr_info#parent_path.)[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).idx];
196 } else {
197 node_visit_tcxx . . $ node_visit_t#* node;
198
199 while (num > 0) {
200 node = &(*btr_cur->rtr_infocxx . . $ btr_cur_t#rtr_info.->parent_pathcxx . . $ rtr_info#parent_path.)[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).num - 1];
201
202 if (node->levelcxx . . $ node_visit_t#level. == level) {
203 found_node = node;
204 break;
205 }
206 num--;
207 }
208 }
209
210 mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&btr_cur->rtr_info->rtr_path_mutex);
211
212 return(found_node);
213 }
214
215 /*********************************************************//**
216 Returns the R-Tree cursor stored in the parent search path
217 @return pointer to R-Tree cursor component */
218 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
219 btr_pcur_tcxx . . $ btr_pcur_t#*
220 rtr_get_parent_cursorcxx . . $ rtr_get_parent_cursor(285591353767c8f9).(
221 /*==================*/
222 btr_cur_tcxx . . $ btr_cur_t#* btr_cur, /*!< in: persistent cursor */
223 ulintcxx . . $ ulint# level, /*!< in: index level of buffer page */
224 ulintcxx . . $ ulint# is_insert) /*!< in: whether insert operation */
225 {
226 node_visit_tcxx . . $ node_visit_t#* found_node = rtr_get_parent_nodecxx . . $ rtr_get_parent_node(1e31f6e0524f29af).(
227 btr_cur, level, is_insert);
228
229 return((found_node) ? found_node->cursorcxx . . $ node_visit_t#cursor. : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
230 }
231
232 /********************************************************************//**
233 Reinitialize a R-Tree search info in btr_cur_t */
234 UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`!
235 void
236 rtr_info_reinit_in_cursorcxx . . $ rtr_info_reinit_in_cursor(946616213f38efef).(
237 /************************/
238 btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in/out: tree cursor */
239 dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index struct */
240 bool need_prdt) /*!< in: Whether predicate lock is
241 needed */
242 {
243 que_thr_tcxx . . $ que_thr_t#* thr = cursor->rtr_infocxx . . $ btr_cur_t#rtr_info.->thrcxx . . $ rtr_info#thr.;
244 ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr);
245 rtr_clean_rtr_infocxx . . $ rtr_clean_rtr_info(297f4d0a6e845a99).(cursor->rtr_infocxx . . $ btr_cur_t#rtr_info., false);
246 rtr_init_rtr_infocxx . . $ rtr_init_rtr_info(8b8a56c3073d5c77).(cursor->rtr_infocxx . . $ btr_cur_t#rtr_info., need_prdt, cursor, index, true);
247 cursor->rtr_infocxx . . $ btr_cur_t#rtr_info.->thrcxx . . $ rtr_info#thr. = thr;
248 }