MySQL 8.0.40
Source Code Documentation
|
R-tree header file. More...
#include "univ.i"
#include "btr0cur.h"
#include "btr0types.h"
#include "data0type.h"
#include "data0types.h"
#include "dict0types.h"
#include "gis0geo.h"
#include "gis0type.h"
#include "hash0hash.h"
#include "mem0mem.h"
#include "page0page.h"
#include "que0types.h"
#include "rem0types.h"
#include "row0types.h"
#include "trx0types.h"
#include "ut0vec.h"
#include "ut0wqueue.h"
#include "gis0rtree.ic"
Go to the source code of this file.
Functions | |
static bool | RTREE_SEARCH_MODE (page_cur_mode_t mode) |
dtuple_t * | rtr_index_build_node_ptr (const dict_index_t *index, const rtr_mbr_t *mbr, const rec_t *rec, page_no_t page_no, mem_heap_t *heap) |
Builds a Rtree node pointer out of a physical record and a page number. More... | |
rec_t * | rtr_page_split_and_insert (uint32_t flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, const dtuple_t *tuple, mtr_t *mtr) |
Splits an R-tree index page to halves and inserts the tuple. More... | |
static void | rtr_page_cal_mbr (const dict_index_t *index, const buf_block_t *block, rtr_mbr_t *mbr, mem_heap_t *heap) |
Sets the child node mbr in a node pointer. More... | |
bool | rtr_pcur_move_to_next (const dtuple_t *tuple, page_cur_mode_t mode, select_mode sel_mode, btr_pcur_t *cursor, ulint cur_level, mtr_t *mtr) |
Find the next matching record. More... | |
bool | rtr_cur_search_with_match (const buf_block_t *block, dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, page_cur_t *cursor, rtr_info_t *rtr_info) |
Searches the right position in rtree for a page cursor. More... | |
double | rtr_rec_cal_increase (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, double *area, const dd::Spatial_reference_system *srs) |
Calculate the area increased for a new record. More... | |
dberr_t | rtr_ins_enlarge_mbr (btr_cur_t *btr_cur, mtr_t *mtr) |
Following the right link to find the proper block for insert. More... | |
void | rtr_get_father_node (dict_index_t *index, ulint level, const dtuple_t *tuple, btr_cur_t *sea_cur, btr_cur_t *cursor, page_no_t page_no, mtr_t *mtr) |
in: mtr More... | |
static void | rtr_non_leaf_stack_push (rtr_node_path_t *path, page_no_t pageno, node_seq_t seq_no, ulint level, page_no_t child_no, btr_pcur_t *cursor, double mbr_inc) |
Push a nonleaf index node to the search path. More... | |
void | rtr_non_leaf_insert_stack_push (dict_index_t *index, rtr_node_path_t *path, ulint level, const buf_block_t *block, const rec_t *rec, double mbr_inc) |
Push a nonleaf index node to the search path for insertion. More... | |
static node_seq_t | rtr_get_new_ssn_id (dict_index_t *index) |
Allocates a new Split Sequence Number. More... | |
static node_seq_t | rtr_get_current_ssn_id (dict_index_t *index) |
Get the current Split Sequence Number. More... | |
rtr_info_t * | rtr_create_rtr_info (bool need_prdt, bool init_matches, btr_cur_t *cursor, dict_index_t *index) |
Create a RTree search info structure. More... | |
void | rtr_info_update_btr (btr_cur_t *cursor, rtr_info_t *rtr_info) |
Update a btr_cur_t with rtr_info. More... | |
void | rtr_init_rtr_info (rtr_info_t *rtr_info, bool need_prdt, btr_cur_t *cursor, dict_index_t *index, bool reinit) |
Update a btr_cur_t with rtr_info. More... | |
void | rtr_clean_rtr_info (rtr_info_t *rtr_info, bool free_all) |
Clean up Rtree cursor. More... | |
void | rtr_get_mbr_from_rec (const rec_t *rec, const ulint *offsets, rtr_mbr_t *mbr) |
Get the bounding box content from an index record. More... | |
void | rtr_get_mbr_from_tuple (const dtuple_t *dtuple, rtr_mbr *mbr) |
Get the bounding box content from a MBR data record. More... | |
void | rtr_page_get_father (dict_index_t *index, buf_block_t *block, mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor) |
ulint * | rtr_page_get_father_block (ulint *offsets, mem_heap_t *heap, dict_index_t *index, buf_block_t *block, mtr_t *mtr, btr_cur_t *sea_cur, btr_cur_t *cursor) |
Returns the father block to a page. More... | |
ulint | rtr_store_parent_path (const buf_block_t *block, btr_cur_t *btr_cur, ulint latch_mode, ulint level, mtr_t *mtr) |
Store the parent path cursor. More... | |
void | rtr_pcur_open_low (dict_index_t *index, ulint level, const dtuple_t *tuple, page_cur_mode_t mode, ulint latch_mode, btr_pcur_t *cursor, ut::Location location, mtr_t *mtr) |
Initializes and opens a persistent cursor to an index tree. More... | |
static void | rtr_pcur_open (dict_index_t *i, const dtuple_t *t, page_cur_mode_t md, ulint l, btr_pcur_t *c, ut::Location loc, mtr_t *m) |
static node_visit_t * | rtr_get_parent_node (btr_cur_t *btr_cur, ulint level, ulint is_insert) |
Returns the R-Tree node stored in the parent search path. More... | |
static btr_pcur_t * | rtr_get_parent_cursor (btr_cur_t *btr_cur, ulint level, ulint is_insert) |
Returns the R-Tree cursor stored in the parent search path. More... | |
void | rtr_page_copy_rec_list_end_no_locks (buf_block_t *new_block, buf_block_t *block, rec_t *rec, dict_index_t *index, mem_heap_t *heap, rtr_rec_move_t *rec_move, ulint max_move, ulint *num_moved, mtr_t *mtr) |
Copy recs from a page to new_block of rtree. More... | |
void | rtr_page_copy_rec_list_start_no_locks (buf_block_t *new_block, buf_block_t *block, rec_t *rec, dict_index_t *index, mem_heap_t *heap, rtr_rec_move_t *rec_move, ulint max_move, ulint *num_moved, mtr_t *mtr) |
Copy recs till a specified rec from a page to new_block of rtree. More... | |
dberr_t | rtr_merge_and_update_mbr (btr_cur_t *cursor, btr_cur_t *cursor2, ulint *offsets, ulint *offsets2, page_t *child_page, mtr_t *mtr) |
Merge 2 mbrs and update the the mbr that cursor is on. More... | |
void | rtr_node_ptr_delete (btr_cur_t *sea_cur, mtr_t *mtr) |
Deletes on the upper level the node pointer to a page. More... | |
bool | rtr_merge_mbr_changed (btr_cur_t *cursor, btr_cur_t *cursor2, ulint *offsets, ulint *offsets2, rtr_mbr_t *new_mbr) |
Check two MBRs are identical or need to be merged. More... | |
bool | rtr_update_mbr_field (btr_cur_t *cursor, ulint *offsets, btr_cur_t *cursor2, page_t *child_page, rtr_mbr_t *new_mbr, rec_t *new_rec, mtr_t *mtr) |
Update the mbr field of a spatial index row. More... | |
bool | rtr_check_same_block (dict_index_t *index, btr_cur_t *cur, buf_block_t *parentb, buf_block_t *childb, mem_heap_t *heap) |
Check whether a Rtree page is child of a parent page. More... | |
static void | rtr_write_mbr (byte *data, const rtr_mbr_t *mbr) |
Sets pointer to the data and length in a field. More... | |
static void | rtr_read_mbr (const byte *data, rtr_mbr_t *mbr) |
Sets pointer to the data and length in a field. More... | |
void | rtr_check_discard_page (dict_index_t *index, btr_cur_t *cursor, buf_block_t *block) |
Check whether a discarding page is in anyone's search path. More... | |
static void | rtr_info_reinit_in_cursor (btr_cur_t *cursor, dict_index_t *index, bool need_prdt) |
Reinitialize a RTree search info. More... | |
int64_t | rtr_estimate_n_rows_in_range (dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode) |
Estimates the number of rows in a given area. More... | |
Variables | |
constexpr uint32_t | GEO_DATA_HEADER_SIZE = 4 |
R-tree header file.
Created 2013/03/27 Jimmy Yang and Allen Lai
void rtr_check_discard_page | ( | dict_index_t * | index, |
btr_cur_t * | cursor, | ||
buf_block_t * | block | ||
) |
Check whether a discarding page is in anyone's search path.
[in] | index | Index |
[in,out] | cursor | Cursor on the page to discard: not on the root page |
[in] | block | Block of page to be discarded |
bool rtr_check_same_block | ( | dict_index_t * | index, |
btr_cur_t * | cursor, | ||
buf_block_t * | parentb, | ||
buf_block_t * | childb, | ||
mem_heap_t * | heap | ||
) |
Check whether a Rtree page is child of a parent page.
index | in: index tree |
cursor | in/out: position at the parent entry pointing to the child if successful |
parentb | in: parent page to check |
childb | in: child Page |
heap | in: memory heap |
void rtr_clean_rtr_info | ( | rtr_info_t * | rtr_info, |
bool | free_all | ||
) |
Clean up Rtree cursor.
in: need to free rtr_info itself
Clean up Rtree cursor.
rtr_info | in: RTree search info |
free_all | in: need to free rtr_info itself |
rtr_info_t * rtr_create_rtr_info | ( | bool | need_prdt, |
bool | init_matches, | ||
btr_cur_t * | cursor, | ||
dict_index_t * | index | ||
) |
Create a RTree search info structure.
[in] | need_prdt | Whether predicate lock is needed |
[in] | init_matches | Whether to initiate the "matches" structure for collecting matched leaf records |
[in] | cursor | Tree search cursor |
[in] | index | Index struct |
bool rtr_cur_search_with_match | ( | const buf_block_t * | block, |
dict_index_t * | index, | ||
const dtuple_t * | tuple, | ||
page_cur_mode_t | mode, | ||
page_cur_t * | cursor, | ||
rtr_info_t * | rtr_info | ||
) |
Searches the right position in rtree for a page cursor.
[in] | block | Buffer block |
[in] | index | Index descriptor |
[in] | tuple | Data tuple |
[in] | mode | Page_cur_l, page_cur_le, page_cur_g, or page_cur_ge |
[in,out] | cursor | Page cursor |
[in,out] | rtr_info | Search stack |
int64_t rtr_estimate_n_rows_in_range | ( | dict_index_t * | index, |
const dtuple_t * | tuple, | ||
page_cur_mode_t | mode | ||
) |
Estimates the number of rows in a given area.
[in] | index | index |
[in] | tuple | range tuple containing mbr, may also be empty tuple |
[in] | mode | search mode |
|
inlinestatic |
Get the current Split Sequence Number.
void rtr_get_father_node | ( | dict_index_t * | index, |
ulint | level, | ||
const dtuple_t * | tuple, | ||
btr_cur_t * | sea_cur, | ||
btr_cur_t * | btr_cur, | ||
page_no_t | page_no, | ||
mtr_t * | mtr | ||
) |
in: mtr
in: mtr
It is assumed that mtr holds an x-latch on the tree.
index | in: index |
level | in: the tree level of search |
tuple | in: data tuple; NOTE: n_fields_cmp in tuple must be set so that it cannot get compared to the node ptr page number field! |
sea_cur | in: search cursor |
btr_cur | in/out: tree cursor; the cursor page is s- or x-latched, but see also above! |
page_no | Current page no |
mtr | in: mtr |
Get the bounding box content from an index record.
[in] | rec | Data tuple |
[in] | offsets | Offsets array |
[out] | mbr | Mbr |
Get the bounding box content from a MBR data record.
[in] | dtuple | Data tuple |
[out] | mbr | Mbr to fill |
dtuple | in: data tuple |
mbr | out: mbr to fill |
|
inlinestatic |
Allocates a new Split Sequence Number.
|
inlinestatic |
Returns the R-Tree cursor stored in the parent search path.
[in] | btr_cur | persistent cursor |
[in] | level | index level of buffer page |
[in] | is_insert | whether insert operation |
|
inlinestatic |
Returns the R-Tree node stored in the parent search path.
[in] | btr_cur | persistent cursor |
[in] | level | index level of buffer page |
[in] | is_insert | whether insert operation |
dtuple_t * rtr_index_build_node_ptr | ( | const dict_index_t * | index, |
const rtr_mbr_t * | mbr, | ||
const rec_t * | rec, | ||
page_no_t | page_no, | ||
mem_heap_t * | heap | ||
) |
Builds a Rtree node pointer out of a physical record and a page number.
[in] | index | index |
[in] | mbr | mbr of lower page |
[in] | rec | record for which to build node pointer |
[in] | page_no | page number to put in node pointer |
[in] | heap | memory heap where pointer created |
|
inlinestatic |
Reinitialize a RTree search info.
[in,out] | cursor | tree cursor |
[in] | index | index struct |
[in] | need_prdt | Whether predicate lock is needed |
void rtr_info_update_btr | ( | btr_cur_t * | cursor, |
rtr_info_t * | rtr_info | ||
) |
Update a btr_cur_t with rtr_info.
[in,out] | cursor | Tree cursor |
[in] | rtr_info | Rtr_info to set to the cursor |
void rtr_init_rtr_info | ( | rtr_info_t * | rtr_info, |
bool | need_prdt, | ||
btr_cur_t * | cursor, | ||
dict_index_t * | index, | ||
bool | reinit | ||
) |
Update a btr_cur_t with rtr_info.
in: Whether this is a reinit
Update a btr_cur_t with rtr_info.
rtr_info | ************* in: rtr_info to set to the cursor |
need_prdt | in: Whether predicate lock is needed |
cursor | in: tree search cursor |
index | in: index structure |
reinit | in: Whether this is a reinit |
Following the right link to find the proper block for insert.
[in] | btr_cur | btr cursor |
[in] | mtr | mtr |
dberr_t rtr_merge_and_update_mbr | ( | btr_cur_t * | cursor, |
btr_cur_t * | cursor2, | ||
ulint * | offsets, | ||
ulint * | offsets2, | ||
page_t * | child_page, | ||
mtr_t * | mtr | ||
) |
Merge 2 mbrs and update the the mbr that cursor is on.
[in,out] | cursor | Cursor |
[in] | cursor2 | The other cursor |
[in] | offsets | Rec offsets |
[in] | offsets2 | Rec offsets |
[in] | child_page | The child page. |
[in] | mtr | Mini-transaction |
bool rtr_merge_mbr_changed | ( | btr_cur_t * | cursor, |
btr_cur_t * | cursor2, | ||
ulint * | offsets, | ||
ulint * | offsets2, | ||
rtr_mbr_t * | new_mbr | ||
) |
Check two MBRs are identical or need to be merged.
[in] | cursor | Cursor |
[in] | cursor2 | The other cursor |
[in] | offsets | Rec offsets |
[in] | offsets2 | Rec offsets |
[out] | new_mbr | Mbr to update |
Deletes on the upper level the node pointer to a page.
[in] | sea_cur | Search cursor, contains information about parent nodes in search |
[in] | mtr | Mini-transaction |
void rtr_non_leaf_insert_stack_push | ( | dict_index_t * | index, |
rtr_node_path_t * | path, | ||
ulint | level, | ||
const buf_block_t * | block, | ||
const rec_t * | rec, | ||
double | mbr_inc | ||
) |
Push a nonleaf index node to the search path for insertion.
[in] | index | index descriptor |
[in,out] | path | search path |
[in] | level | index level |
[in] | block | block of the page |
[in] | rec | positioned record |
[in] | mbr_inc | MBR needs to be enlarged |
|
inlinestatic |
Push a nonleaf index node to the search path.
[in,out] | path | search path |
[in] | pageno | pageno to insert |
[in] | seq_no | Node sequence num |
[in] | level | index level |
[in] | child_no | child page no |
[in] | cursor | position cursor |
[in] | mbr_inc | MBR needs to be enlarged |
|
inlinestatic |
Sets the child node mbr in a node pointer.
[in] | index | index |
[in] | block | buffer block |
[out] | mbr | MBR encapsulates the page |
[in] | heap | heap for the memory allocation |
void rtr_page_copy_rec_list_end_no_locks | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | rec, | ||
dict_index_t * | index, | ||
mem_heap_t * | heap, | ||
rtr_rec_move_t * | rec_move, | ||
ulint | max_move, | ||
ulint * | num_moved, | ||
mtr_t * | mtr | ||
) |
Copy recs from a page to new_block of rtree.
Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page.
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block is a compressed leaf page in a secondary index. This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit().
[in] | new_block | Index page to copy to |
[in] | block | Index page of rec |
[in] | rec | Record on page |
[in] | index | Record descriptor |
[in,out] | heap | Heap memory |
[in] | rec_move | Recording records moved |
[in] | max_move | Num of rec to move |
[out] | num_moved | Num of rec to move |
[in] | mtr | Mini-transaction |
void rtr_page_copy_rec_list_start_no_locks | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | rec, | ||
dict_index_t * | index, | ||
mem_heap_t * | heap, | ||
rtr_rec_move_t * | rec_move, | ||
ulint | max_move, | ||
ulint * | num_moved, | ||
mtr_t * | mtr | ||
) |
Copy recs till a specified rec from a page to new_block of rtree.
[in] | new_block | Index page to copy to |
[in] | block | Index page of rec |
[in] | rec | Record on page |
[in] | index | Record descriptor |
[in,out] | heap | Heap memory |
[in] | rec_move | Recording records moved |
[in] | max_move | Num of rec to move |
[out] | num_moved | Num of rec to move |
[in] | mtr | Mini-transaction |
void rtr_page_get_father | ( | dict_index_t * | index, |
buf_block_t * | block, | ||
mtr_t * | mtr, | ||
btr_cur_t * | sea_cur, | ||
btr_cur_t * | cursor | ||
) |
ulint * rtr_page_get_father_block | ( | ulint * | offsets, |
mem_heap_t * | heap, | ||
dict_index_t * | index, | ||
buf_block_t * | block, | ||
mtr_t * | mtr, | ||
btr_cur_t * | sea_cur, | ||
btr_cur_t * | cursor | ||
) |
Returns the father block to a page.
It is assumed that mtr holds an X or SX latch on the tree.
It is assumed that mtr holds an X or SX latch on the tree.
offsets | in: work area for the return value |
heap | in: memory heap to use |
index | in: b-tree index |
block | in: child page in the index |
mtr | in: mtr |
sea_cur | in: search cursor, contains information about parent nodes in search |
cursor | out: cursor on node pointer record, its page x-latched |
rec_t * rtr_page_split_and_insert | ( | uint32_t | flags, |
btr_cur_t * | cursor, | ||
ulint ** | offsets, | ||
mem_heap_t ** | heap, | ||
const dtuple_t * | tuple, | ||
mtr_t * | mtr | ||
) |
Splits an R-tree index page to halves and inserts the tuple.
It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space (2 pages) must be guaranteed to be available before this function is called.
It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space (2 pages) must be guaranteed to be available before this function is called.
flags | in: undo logging and locking flags |
cursor | in/out: cursor at which to insert; when the function returns, the cursor is positioned on the predecessor of the inserted record |
offsets | out: offsets on inserted record |
heap | in/out: pointer to memory heap, or NULL |
tuple | in: tuple to insert |
mtr | in: mtr |
bool rtr_pcur_move_to_next | ( | const dtuple_t * | tuple, |
page_cur_mode_t | mode, | ||
select_mode | sel_mode, | ||
btr_pcur_t * | cursor, | ||
ulint | cur_level, | ||
mtr_t * | mtr | ||
) |
Find the next matching record.
This function will first exhaust the copied record listed in the rtr_info->matches vector before moving to next page
[in] | tuple | Data tuple; NOTE: n_fields_cmp in tuple must be set so that it cannot get compared to the node ptr page number field! |
[in] | mode | Cursor search mode |
[in] | sel_mode | Select mode: SELECT_ORDINARY, SELECT_SKIP_LOKCED, or SELECT_NO_WAIT |
[in] | cursor | Persistent cursor; NOTE that the function may release the page latch |
[in] | cur_level | Current level |
[in] | mtr | Mini-transaction |
|
inlinestatic |
void rtr_pcur_open_low | ( | dict_index_t * | index, |
ulint | level, | ||
const dtuple_t * | tuple, | ||
page_cur_mode_t | mode, | ||
ulint | latch_mode, | ||
btr_pcur_t * | cursor, | ||
ut::Location | location, | ||
mtr_t * | mtr | ||
) |
Initializes and opens a persistent cursor to an index tree.
It should be closed with btr_pcur::close. Mainly called by row_search_index_entry()
[in] | index | index |
[in] | level | level in the btree |
[in] | tuple | tuple on which search done |
[in] | mode | PAGE_CUR_L, ...; NOTE that if the search is made using a unique prefix of a record, mode should be PAGE_CUR_LE, not PAGE_CUR_GE, as the latter may end up on the previous page from the record! |
[in] | latch_mode | BTR_SEARCH_LEAF, ... |
[in] | cursor | memore buffer for persistent cursor |
[in] | location | location where called |
[in] | mtr | mtr |
Sets pointer to the data and length in a field.
[in] | data | data |
[out] | mbr | data |
double rtr_rec_cal_increase | ( | const dtuple_t * | dtuple, |
const rec_t * | rec, | ||
const ulint * | offsets, | ||
double * | area, | ||
const dd::Spatial_reference_system * | srs | ||
) |
Calculate the area increased for a new record.
dtuple | in: data tuple to insert, which cause area increase |
rec | in: physical record which differs from dtuple in some of the common fields, or which has an equal number or more fields than dtuple |
offsets | in: array returned by rec_get_offsets() |
area | out: increased area |
srs | in: SRS of R-tree |
ulint rtr_store_parent_path | ( | const buf_block_t * | block, |
btr_cur_t * | btr_cur, | ||
ulint | latch_mode, | ||
ulint | level, | ||
mtr_t * | mtr | ||
) |
Store the parent path cursor.
block | in: block of the page |
btr_cur | in/out: persistent cursor |
latch_mode | in: latch_mode |
level | in: index level |
mtr | in: mtr |
bool rtr_update_mbr_field | ( | btr_cur_t * | cursor, |
ulint * | offsets, | ||
btr_cur_t * | cursor2, | ||
page_t * | child_page, | ||
rtr_mbr_t * | mbr, | ||
rec_t * | new_rec, | ||
mtr_t * | mtr | ||
) |
Update the mbr field of a spatial index row.
cursor | in/out: cursor pointed to rec. |
offsets | in/out: offsets on rec. |
cursor2 | in/out: cursor pointed to rec that should be deleted. this cursor is for btr_compress to delete the merged page's father rec. |
child_page | in: child page. |
mbr | in: the new mbr. |
new_rec | in: rec to use |
mtr | in: mtr |
Sets pointer to the data and length in a field.
[out] | data | data |
[in] | mbr | data |
|
inlinestatic |
|
constexpr |