summaryrefslogtreecommitdiff
path: root/myisam/mi_range.c
diff options
context:
space:
mode:
authorunknown <bar@gw.udmsearch.izhnet.ru>2002-02-20 14:11:21 +0400
committerunknown <bar@gw.udmsearch.izhnet.ru>2002-02-20 14:11:21 +0400
commit3d5dc65dfd72083ed159220d03bea942094e8662 (patch)
tree20573ea174df56ec053e23fa07eb87679f3b7a38 /myisam/mi_range.c
parentb87d6ee9d730fb2df74a3981b552b0da2e09570c (diff)
downloadmariadb-git-3d5dc65dfd72083ed159220d03bea942094e8662.tar.gz
This ChangeSet adds RTREE support into myisam library.
RTREEs will be used for GIS extension in MySQL myisam/.cvsignore: Added sp_test and rt_test myisam/Makefile.am: Added RTREE files myisam/mi_create.c: Added RTREE/SPATIAL initialization myisam/mi_delete.c: Switched to use virual function, instead of mi_ck_delete() direct call myisam/mi_key.c: Added sp_make_key() call in the case of SPATIAL index type myisam/mi_open.c: Added some new initialization actions which depend on key_alg being used: RTREE or BTREE myisam/mi_range.c: Rtree estimation myisam/mi_rkey.c: rtree myisam/mi_rnext.c: rtree myisam/mi_rnext_same.c: rtree myisam/mi_static.c: New search flags for bounding rectungles myisam/mi_test1.c: one now should always specify key_alg during keyinfo initializing: BTREE or RTREE myisam/mi_test2.c: Added key_alg initializing myisam/mi_test3.c: Added key_alg initialization myisam/mi_update.c: Switched to virtual functions, instead of mi_ck_delete/mi_ck_write direct call myisam/mi_write.c: Virtual function instead of mi_ck_write() direct call myisam/myisamdef.h: Rtree additions
Diffstat (limited to 'myisam/mi_range.c')
-rw-r--r--myisam/mi_range.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/myisam/mi_range.c b/myisam/mi_range.c
index 70694bf4620..4b98b48199a 100644
--- a/myisam/mi_range.c
+++ b/myisam/mi_range.c
@@ -20,6 +20,7 @@
*/
#include "myisamdef.h"
+#include "rt_index.h"
static ha_rows _mi_record_pos(MI_INFO *info,const byte *key,uint key_len,
enum ha_rkey_function search_flag);
@@ -39,7 +40,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
const byte *end_key, uint end_key_len,
enum ha_rkey_function end_search_flag)
{
- ha_rows start_pos,end_pos;
+ ha_rows start_pos,end_pos,res;
DBUG_ENTER("mi_records_in_range");
if ((inx = _mi_check_index(info,inx)) < 0)
@@ -50,20 +51,39 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
info->update&= (HA_STATE_CHANGED+HA_STATE_ROW_CHANGED);
if (info->s->concurrent_insert)
rw_rdlock(&info->s->key_root_lock[inx]);
- start_pos= (start_key ?
+
+ switch(info->s->keyinfo[inx].key_alg){
+ case HA_KEY_ALG_RTREE:
+ {
+ uchar * key_buff;
+ if (start_key_len == 0)
+ start_key_len=USE_WHOLE_KEY;
+ key_buff=info->lastkey+info->s->base.max_key_length;
+ start_key_len=_mi_pack_key(info,inx,key_buff,(uchar*) start_key,start_key_len);
+ res=rtree_estimate(info, inx, key_buff, start_key_len, myisam_read_vec[start_search_flag]);
+ res=res?res:1;
+ break;
+ }
+ case HA_KEY_ALG_BTREE:
+ default:
+ start_pos= (start_key ?
_mi_record_pos(info,start_key,start_key_len,start_search_flag) :
(ha_rows) 0);
- end_pos= (end_key ?
+ end_pos= (end_key ?
_mi_record_pos(info,end_key,end_key_len,end_search_flag) :
info->state->records+ (ha_rows) 1);
+ res=end_pos < start_pos ? (ha_rows) 0 :
+ (end_pos == start_pos ? (ha_rows) 1 : end_pos-start_pos);
+ if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR)
+ res=HA_POS_ERROR;
+ }
+
if (info->s->concurrent_insert)
rw_unlock(&info->s->key_root_lock[inx]);
fast_mi_writeinfo(info);
- if (start_pos == HA_POS_ERROR || end_pos == HA_POS_ERROR)
- DBUG_RETURN(HA_POS_ERROR);
- DBUG_PRINT("info",("records: %ld",(ulong) (end_pos-start_pos)));
- DBUG_RETURN(end_pos < start_pos ? (ha_rows) 0 :
- (end_pos == start_pos ? (ha_rows) 1 : end_pos-start_pos));
+
+ DBUG_PRINT("info",("records: %ld",(ulong) (res)));
+ DBUG_RETURN(res);
}