Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9b1313e8
Commit
9b1313e8
authored
Apr 30, 2018
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtr_estimate_n_rows_in_range(): Simplify code
parent
935025f8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
40 deletions
+25
-40
storage/innobase/gis/gis0rtree.cc
storage/innobase/gis/gis0rtree.cc
+25
-40
No files found.
storage/innobase/gis/gis0rtree.cc
View file @
9b1313e8
...
@@ -1849,6 +1849,8 @@ rtr_estimate_n_rows_in_range(
...
@@ -1849,6 +1849,8 @@ rtr_estimate_n_rows_in_range(
const
dtuple_t
*
tuple
,
const
dtuple_t
*
tuple
,
page_cur_mode_t
mode
)
page_cur_mode_t
mode
)
{
{
ut_ad
(
dict_index_is_spatial
(
index
));
/* Check tuple & mode */
/* Check tuple & mode */
if
(
tuple
->
n_fields
==
0
)
{
if
(
tuple
->
n_fields
==
0
)
{
return
(
HA_POS_ERROR
);
return
(
HA_POS_ERROR
);
...
@@ -1870,35 +1872,31 @@ rtr_estimate_n_rows_in_range(
...
@@ -1870,35 +1872,31 @@ rtr_estimate_n_rows_in_range(
);
);
/* Read mbr from tuple. */
/* Read mbr from tuple. */
const
dfield_t
*
dtuple_field
;
ulint
dtuple_f_len
MY_ATTRIBUTE
((
unused
));
rtr_mbr_t
range_mbr
;
rtr_mbr_t
range_mbr
;
double
range_area
;
double
range_area
;
byte
*
range_mbr_ptr
;
const
byte
*
range_mbr_ptr
;
dtuple_field
=
dtuple_get_nth_field
(
tuple
,
0
);
const
dfield_t
*
dtuple_field
=
dtuple_get_nth_field
(
tuple
,
0
);
dtuple_f_len
=
dfield_get_len
(
dtuple_field
);
ut_ad
(
dfield_get_len
(
dtuple_field
)
>=
DATA_MBR_LEN
);
range_mbr_ptr
=
reinterpret_cast
<
byte
*>
(
dfield_get_data
(
dtuple_field
));
range_mbr_ptr
=
reinterpret_cast
<
const
byte
*>
(
dfield_get_data
(
dtuple_field
));
ut_ad
(
dtuple_f_len
>=
DATA_MBR_LEN
);
rtr_read_mbr
(
range_mbr_ptr
,
&
range_mbr
);
rtr_read_mbr
(
range_mbr_ptr
,
&
range_mbr
);
range_area
=
(
range_mbr
.
xmax
-
range_mbr
.
xmin
)
range_area
=
(
range_mbr
.
xmax
-
range_mbr
.
xmin
)
*
(
range_mbr
.
ymax
-
range_mbr
.
ymin
);
*
(
range_mbr
.
ymax
-
range_mbr
.
ymin
);
/* Get index root page. */
/* Get index root page. */
mtr_t
mtr
;
mtr_t
mtr
;
buf_block_t
*
block
;
page_t
*
page
;
mtr
.
start
();
mtr
.
start
();
index
->
set_modified
(
mtr
);
index
->
set_modified
(
mtr
);
mtr_s_lock
(
&
index
->
lock
,
&
mtr
);
mtr_s_lock
(
&
index
->
lock
,
&
mtr
);
block
=
btr_block_get
(
b
uf_block_t
*
b
lock
=
btr_block_get
(
page_id_t
(
index
->
table
->
space
->
id
,
index
->
page
),
page_id_t
(
index
->
table
->
space
->
id
,
index
->
page
),
page_size_t
(
index
->
table
->
space
->
flags
),
page_size_t
(
index
->
table
->
space
->
flags
),
RW_S_LATCH
,
index
,
&
mtr
);
RW_S_LATCH
,
index
,
&
mtr
);
page
=
buf_block_get_frame
(
block
);
const
page_t
*
page
=
buf_block_get_frame
(
block
);
const
unsigned
n_recs
=
page_header_get_field
(
page
,
PAGE_N_RECS
);
const
unsigned
n_recs
=
page_header_get_field
(
page
,
PAGE_N_RECS
);
if
(
n_recs
==
0
)
{
if
(
n_recs
==
0
)
{
...
@@ -1906,27 +1904,16 @@ rtr_estimate_n_rows_in_range(
...
@@ -1906,27 +1904,16 @@ rtr_estimate_n_rows_in_range(
return
(
HA_POS_ERROR
);
return
(
HA_POS_ERROR
);
}
}
rec_t
*
rec
;
byte
*
field
;
ulint
len
;
ulint
*
offsets
=
NULL
;
mem_heap_t
*
heap
;
heap
=
mem_heap_create
(
512
);
rec
=
page_rec_get_next
(
page_get_infimum_rec
(
page
));
offsets
=
rec_get_offsets
(
rec
,
index
,
offsets
,
page_rec_is_leaf
(
rec
),
ULINT_UNDEFINED
,
&
heap
);
/* Scan records in root page and calculate area. */
/* Scan records in root page and calculate area. */
double
area
=
0
;
double
area
=
0
;
while
(
!
page_rec_is_supremum
(
rec
))
{
for
(
const
rec_t
*
rec
=
page_rec_get_next
(
page_get_infimum_rec
(
block
->
frame
));
!
page_rec_is_supremum
(
rec
);
rec
=
page_rec_get_next_const
(
rec
))
{
rtr_mbr_t
mbr
;
rtr_mbr_t
mbr
;
double
rec_area
;
double
rec_area
;
field
=
rec_get_nth_field
(
rec
,
offsets
,
0
,
&
len
);
rtr_read_mbr
(
rec
,
&
mbr
);
ut_ad
(
len
==
DATA_MBR_LEN
);
rtr_read_mbr
(
field
,
&
mbr
);
rec_area
=
(
mbr
.
xmax
-
mbr
.
xmin
)
*
(
mbr
.
ymax
-
mbr
.
ymin
);
rec_area
=
(
mbr
.
xmax
-
mbr
.
xmin
)
*
(
mbr
.
ymax
-
mbr
.
ymin
);
...
@@ -1944,7 +1931,7 @@ rtr_estimate_n_rows_in_range(
...
@@ -1944,7 +1931,7 @@ rtr_estimate_n_rows_in_range(
case
PAGE_CUR_MBR_EQUAL
:
case
PAGE_CUR_MBR_EQUAL
:
if
(
rtree_key_cmp
(
if
(
rtree_key_cmp
(
PAGE_CUR_WITHIN
,
range_mbr_ptr
,
PAGE_CUR_WITHIN
,
range_mbr_ptr
,
DATA_MBR_LEN
,
field
,
DATA_MBR_LEN
)
DATA_MBR_LEN
,
rec
,
DATA_MBR_LEN
)
==
0
)
{
==
0
)
{
area
+=
1
;
area
+=
1
;
}
}
...
@@ -1958,22 +1945,23 @@ rtr_estimate_n_rows_in_range(
...
@@ -1958,22 +1945,23 @@ rtr_estimate_n_rows_in_range(
switch
(
mode
)
{
switch
(
mode
)
{
case
PAGE_CUR_CONTAIN
:
case
PAGE_CUR_CONTAIN
:
case
PAGE_CUR_INTERSECT
:
case
PAGE_CUR_INTERSECT
:
area
+=
rtree_area_overlapping
(
range_mbr_ptr
,
area
+=
rtree_area_overlapping
(
field
,
DATA_MBR_LEN
)
/
rec_area
;
range_mbr_ptr
,
rec
,
DATA_MBR_LEN
)
/
rec_area
;
break
;
break
;
case
PAGE_CUR_DISJOINT
:
case
PAGE_CUR_DISJOINT
:
area
+=
1
;
area
+=
1
;
area
-=
rtree_area_overlapping
(
range_mbr_ptr
,
area
-=
rtree_area_overlapping
(
field
,
DATA_MBR_LEN
)
/
rec_area
;
range_mbr_ptr
,
rec
,
DATA_MBR_LEN
)
/
rec_area
;
break
;
break
;
case
PAGE_CUR_WITHIN
:
case
PAGE_CUR_WITHIN
:
case
PAGE_CUR_MBR_EQUAL
:
case
PAGE_CUR_MBR_EQUAL
:
if
(
rtree_key_cmp
(
if
(
!
rtree_key_cmp
(
PAGE_CUR_WITHIN
,
range_mbr_ptr
,
PAGE_CUR_WITHIN
,
range_mbr_ptr
,
DATA_MBR_LEN
,
field
,
DATA_MBR_LEN
)
DATA_MBR_LEN
,
rec
,
DATA_MBR_LEN
))
{
==
0
)
{
area
+=
range_area
/
rec_area
;
area
+=
range_area
/
rec_area
;
}
}
...
@@ -1982,12 +1970,9 @@ rtr_estimate_n_rows_in_range(
...
@@ -1982,12 +1970,9 @@ rtr_estimate_n_rows_in_range(
ut_error
;
ut_error
;
}
}
}
}
rec
=
page_rec_get_next
(
rec
);
}
}
mtr
.
commit
();
mtr
.
commit
();
mem_heap_free
(
heap
);
if
(
!
isfinite
(
area
))
{
if
(
!
isfinite
(
area
))
{
return
(
HA_POS_ERROR
);
return
(
HA_POS_ERROR
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment