mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
WL#1562 (Improving spatial code)
A set of changes improving our RTree indexes and fixed few bugs found during the tests myisam/rt_index.c: Algorythm for picking the branch to insert was fixed. pick_by_perimeter version of the algorythm added (mostly for testing purposes) myisam/rt_index.h: minimal size of the page set to 1/3 It noticeable increases searching performance myisam/rt_key.c: counting of the size of the filled part of the page fixed rtree_choose_key moved to rt_index.c myisam/rt_key.h: no need to make rtree_choose_key global myisam/rt_mbr.c: operations for counting the perimeter of MBR added myisam/rt_mbr.h: interface for rtree_perimeter_increase myisam/rt_split.c: my_multi_malloc changed with my_alloca sql/spatial.cc: LINESTRING object can consist of single point
This commit is contained in:
@ -35,7 +35,8 @@ int rtree_add_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
|
||||
uint page_size = mi_getint(page_buf);
|
||||
uint nod_flag = mi_test_if_nod(page_buf);
|
||||
|
||||
if (page_size + key_length + nod_flag <= keyinfo->block_length)
|
||||
if (page_size + key_length + info->s->base.rec_reflength <=
|
||||
keyinfo->block_length)
|
||||
{
|
||||
/* split won't be necessary */
|
||||
if (nod_flag)
|
||||
@ -94,46 +95,3 @@ int rtree_set_key_mbr(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
|
||||
|
||||
return rtree_page_mbr(info, keyinfo->seg, info->buff, key, key_length);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Choose non-leaf better key for insertion
|
||||
*/
|
||||
|
||||
uchar *rtree_choose_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
|
||||
uint key_length, uchar *page_buf, uint nod_flag)
|
||||
{
|
||||
double increase;
|
||||
double best_incr = DBL_MAX;
|
||||
double area;
|
||||
double best_area;
|
||||
uchar *best_key;
|
||||
uchar *k = rt_PAGE_FIRST_KEY(page_buf, nod_flag);
|
||||
uchar *last = rt_PAGE_END(page_buf);
|
||||
|
||||
LINT_INIT(best_area);
|
||||
LINT_INIT(best_key);
|
||||
|
||||
for (; k < last; k = rt_PAGE_NEXT_KEY(k, key_length, nod_flag))
|
||||
{
|
||||
if ((increase = rtree_area_increase(keyinfo->seg, key, k, key_length,
|
||||
&area)) == -1)
|
||||
return NULL;
|
||||
if (increase < best_incr)
|
||||
{
|
||||
best_key = k;
|
||||
best_area = area;
|
||||
best_incr = increase;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((increase == best_incr) && (area < best_area))
|
||||
{
|
||||
best_key = k;
|
||||
best_area = area;
|
||||
best_incr = increase;
|
||||
}
|
||||
}
|
||||
}
|
||||
return best_key;
|
||||
}
|
||||
|
Reference in New Issue
Block a user