summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <serg@serg.mysql.com>2001-09-25 20:31:02 +0200
committerunknown <serg@serg.mysql.com>2001-09-25 20:31:02 +0200
commit734e2a8bcaa4a5d2de6059f4cdcac8e71bbb5d6d (patch)
treea70bc86b1e25c9dd79c1730e066609f2781b606d /myisam
parent51c261ff2393476110d2914bec5f8a1f057555be (diff)
downloadmariadb-git-734e2a8bcaa4a5d2de6059f4cdcac8e71bbb5d6d.tar.gz
get rid of ft_search. Now there're two sets of ft_ functions, ft_nlq_* and ft_boolean_*
BitKeeper/deleted/.del-ft_search.c~c011cb6e8041bb59: Delete: myisam/ft_search.c include/ft_global.h: ft_ --> ft_nlq_ myisam/Makefile.am: get rid of ft_search.c myisam/ft_dump.c: ft_ --> ft_nlq_ myisam/ft_eval.c: ft_ --> ft_nlq_ myisam/ft_nlq_search.c: get rid of ft_search.c myisam/ft_test1.c: ft_ --> ft_nlq_ sql/ha_myisam.cc: ft_ --> ft_nlq_ sql/ha_myisam.h: ft_ --> ft_nlq_ sql/handler.h: cleanup sql/item_func.cc: ft_ --> ft_nlq_ sql/item_func.h: ft_ --> ft_nlq_ sql/item_strfunc.h: cleanup
Diffstat (limited to 'myisam')
-rw-r--r--myisam/Makefile.am2
-rw-r--r--myisam/ft_dump.c4
-rw-r--r--myisam/ft_eval.c8
-rw-r--r--myisam/ft_nlq_search.c64
-rw-r--r--myisam/ft_search.c75
-rw-r--r--myisam/ft_test1.c8
6 files changed, 64 insertions, 97 deletions
diff --git a/myisam/Makefile.am b/myisam/Makefile.am
index 6781116043f..d86462e9b84 100644
--- a/myisam/Makefile.am
+++ b/myisam/Makefile.am
@@ -45,7 +45,7 @@ libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \
mi_range.c mi_dbug.c mi_checksum.c mi_log.c \
mi_changed.c mi_static.c mi_delete_all.c \
mi_delete_table.c mi_rename.c mi_check.c \
- ft_parser.c ft_search.c ft_stopwords.c ft_static.c \
+ ft_parser.c ft_stopwords.c ft_static.c \
ft_update.c ft_boolean_search.c ft_nlq_search.c sort.c
CLEANFILES = test?.MY? FT?.MY? isam.log mi_test_all
DEFS = -DMAP_TO_USE_RAID
diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c
index 42439085132..ee2c3be0710 100644
--- a/myisam/ft_dump.c
+++ b/myisam/ft_dump.c
@@ -77,7 +77,7 @@ int main(int argc,char *argv[])
ft_init_stopwords(ft_precompiled_stopwords);
- result=ft_init_search(info,inx,query,strlen(query),1);
+ result=ft_nlq_init_search(info,inx,query,strlen(query),1);
if(!result)
goto err;
@@ -87,7 +87,7 @@ int main(int argc,char *argv[])
for(i=0 ; i<result->ndocs ; i++)
printf("%9qx %20.7f\n",result->doc[i].dpos,result->doc[i].weight);
- ft_close_search(result);
+ ft_nlq_close_search(result);
}
else
{
diff --git a/myisam/ft_eval.c b/myisam/ft_eval.c
index 9466104100a..1f4b0cb4563 100644
--- a/myisam/ft_eval.c
+++ b/myisam/ft_eval.c
@@ -83,23 +83,23 @@ int main(int argc,char *argv[])
for(i=1;create_record(record,qf);i++) {
FT_DOCLIST *result; double w; int t,err;
- result=ft_init_search(file,0,blob_record,(uint) strlen(blob_record),1);
+ result=ft_nlq_init_search(file,0,blob_record,(uint) strlen(blob_record),1);
if(!result) {
printf("Query %d failed with errno %3d\n",i,my_errno);
goto err;
}
if (!silent)
printf("Query %d. Found: %d.\n",i,result->ndocs);
- for(j=0;(err=ft_read_next(result, read_record))==0;j++) {
+ for(j=0;(err=ft_nlq_read_next(result, read_record))==0;j++) {
t=uint2korr(read_record);
- w=ft_get_relevance(result);
+ w=ft_nlq_get_relevance(result);
printf("%d %.*s %f\n",i,t,read_record+2,w);
}
if(err != HA_ERR_END_OF_FILE) {
printf("ft_read_next %d failed with errno %3d\n",j,my_errno);
goto err;
}
- ft_close_search(result);
+ ft_nlq_close_search(result);
}
if (mi_close(file)) goto err;
diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c
index 350a60708f6..be11c5a9c4c 100644
--- a/myisam/ft_nlq_search.c
+++ b/myisam/ft_nlq_search.c
@@ -147,15 +147,28 @@ static int walk_and_copy(FT_SUPERDOC *from,
return 0;
}
-FT_DOCLIST *ft_nlq_search(MI_INFO *info, uint keynr, byte *query,
- uint query_len)
+static int FT_DOC_cmp(FT_DOC *a, FT_DOC *b)
+{
+ return sgn(b->weight - a->weight);
+}
+
+FT_DOCLIST *ft_nlq_init_search(void *info, uint keynr, byte *query,
+ uint query_len, my_bool presort)
{
TREE *wtree, allocated_wtree;
- ALL_IN_ONE aio;
+ ALL_IN_ONE aio;
FT_DOC *dptr;
FT_DOCLIST *dlist=NULL;
+ my_off_t saved_lastpos=((MI_INFO *)info)->lastpos;
- aio.info=info;
+/* black magic ON */
+ if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0)
+ return NULL;
+ if (_mi_readinfo((MI_INFO *)info,F_RDLCK,1))
+ return NULL;
+/* black magic OFF */
+
+ aio.info=(MI_INFO *)info;
aio.keynr=keynr;
aio.keybuff=aio.info->lastkey+aio.info->s->base.max_key_length;
aio.keyinfo=aio.info->s->keyinfo+keynr;
@@ -167,26 +180,55 @@ FT_DOCLIST *ft_nlq_search(MI_INFO *info, uint keynr, byte *query,
NULL, NULL);
if(!(wtree=ft_parse(&allocated_wtree,query,query_len)))
- return NULL;
+ goto err;
if(tree_walk(wtree, (tree_walk_action)&walk_and_match, &aio,
- left_root_right))
- goto err;
+ left_root_right))
+ goto err2;
- dlist=(FT_DOCLIST *)my_malloc(sizeof(FT_DOCLIST)+sizeof(FT_DOC)*(aio.dtree.elements_in_tree-1),MYF(0));
+ dlist=(FT_DOCLIST *)my_malloc(sizeof(FT_DOCLIST)+
+ sizeof(FT_DOC)*(aio.dtree.elements_in_tree-1),MYF(0));
if(!dlist)
- goto err;
+ goto err2;
dlist->ndocs=aio.dtree.elements_in_tree;
dlist->curdoc=-1;
dlist->info=aio.info;
dptr=dlist->doc;
- tree_walk(&aio.dtree, (tree_walk_action)&walk_and_copy, &dptr, left_root_right);
+ tree_walk(&aio.dtree, (tree_walk_action)&walk_and_copy, &dptr,
+ left_root_right);
-err:
+ if(presort)
+ qsort(dlist->doc, dlist->ndocs, sizeof(FT_DOC), (qsort_cmp)&FT_DOC_cmp);
+
+err2:
delete_tree(wtree);
delete_tree(&aio.dtree);
+
+err:
+ ((MI_INFO *)info)->lastpos=saved_lastpos;
return dlist;
}
+int ft_nlq_read_next(FT_DOCLIST *handler, char *record)
+{
+ MI_INFO *info= (MI_INFO *) handler->info;
+
+ if (++handler->curdoc >= handler->ndocs)
+ {
+ --handler->curdoc;
+ return HA_ERR_END_OF_FILE;
+ }
+
+ info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
+
+ info->lastpos=handler->doc[handler->curdoc].dpos;
+ if (!(*info->read_record)(info,info->lastpos,record))
+ {
+ info->update|= HA_STATE_AKTIV; /* Record is read */
+ return 0;
+ }
+ return my_errno;
+}
+
diff --git a/myisam/ft_search.c b/myisam/ft_search.c
deleted file mode 100644
index 61d169e1507..00000000000
--- a/myisam/ft_search.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/* Written by Sergei A. Golubchik, who has a shared copyright to this code */
-
-#include "ftdefs.h"
-
-/* queries myisam and returns list of documents matched */
-
-static int FT_DOC_cmp(FT_DOC *a, FT_DOC *b)
-{
- return sgn(b->weight - a->weight);
-}
-
-FT_DOCLIST *ft_init_search(void *info, uint keynr, byte *query,
- uint query_len, my_bool presort)
-{
- FT_DOCLIST *dlist;
- my_off_t saved_lastpos=((MI_INFO *)info)->lastpos;
-
-/* black magic ON */
- if ((int) (keynr = _mi_check_index((MI_INFO *)info,keynr)) < 0)
- return NULL;
- if (_mi_readinfo((MI_INFO *)info,F_RDLCK,1))
- return NULL;
-/* black magic OFF */
-
-// if (is_boolean(query, query_len))
-// dlist=ft_boolean_search(info,keynr,query,query_len);
-// else
- dlist=ft_nlq_search(info,keynr,query,query_len);
-
- if(dlist && presort)
- {
- qsort(dlist->doc, dlist->ndocs, sizeof(FT_DOC), (qsort_cmp)&FT_DOC_cmp);
- }
-
- ((MI_INFO *)info)->lastpos=saved_lastpos;
- return dlist;
-}
-
-int ft_read_next(FT_DOCLIST *handler, char *record)
-{
- MI_INFO *info= (MI_INFO *) handler->info;
-
- if (++handler->curdoc >= handler->ndocs)
- {
- --handler->curdoc;
- return HA_ERR_END_OF_FILE;
- }
-
- info->update&= (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
-
- info->lastpos=handler->doc[handler->curdoc].dpos;
- if (!(*info->read_record)(info,info->lastpos,record))
- {
- info->update|= HA_STATE_AKTIV; /* Record is read */
- return 0;
- }
- return my_errno;
-}
-
diff --git a/myisam/ft_test1.c b/myisam/ft_test1.c
index 5093b591fb2..61d9a50e9c3 100644
--- a/myisam/ft_test1.c
+++ b/myisam/ft_test1.c
@@ -137,7 +137,7 @@ static int run_test(const char *filename)
printf("- Reading rows with key\n");
for (i=0 ; i < NQUERIES ; i++)
{ FT_DOCLIST *result;
- result=ft_init_search(file,0,(char*) query[i],strlen(query[i]),1);
+ result=ft_nlq_init_search(file,0,(char*) query[i],strlen(query[i]),1);
if(!result) {
printf("Query %d: `%s' failed with errno %3d\n",i,query[i],my_errno);
continue;
@@ -145,7 +145,7 @@ static int run_test(const char *filename)
printf("Query %d: `%s'. Found: %d. Top five documents:\n",
i,query[i],result->ndocs);
for(j=0;j<5;j++) { double w; int err;
- err=ft_read_next(result, read_record);
+ err=ft_nlq_read_next(result, read_record);
if(err==HA_ERR_END_OF_FILE) {
printf("No more matches!\n");
break;
@@ -153,7 +153,7 @@ static int run_test(const char *filename)
printf("ft_read_next %d failed with errno %3d\n",j,my_errno);
break;
}
- w=ft_get_relevance(result);
+ w=ft_nlq_get_relevance(result);
if(key_field == FIELD_VARCHAR) {
uint l;
char *p;
@@ -164,7 +164,7 @@ static int run_test(const char *filename)
printf("%10.7f: %.*s\n",w,recinfo[1].length,
recinfo[0].length+read_record);
}
- ft_close_search(result);
+ ft_nlq_close_search(result);
}
if (mi_close(file)) goto err;